oracle学习之PLSQL(1)--基础
/*
(一)PLSQL的基本结构
HeaderIS DECLARATION SECTIONBEGIN EXECUTION SECTIONEXCEPTION EXCEPTION SECTIONEND;
DeclareV_num number(4,2);V_char varchar2(20);V_date date;V_boolean Boolean;BeginV_num:=12.22;V_char:='how are you';V_date:='12-1月-2006';V_boolean:=true; Dbms_output.put_line(v_num);Dbms_output.put_line(V_char);Dbms_output.put_line(V_date);-- dbms_output.put_line(v_boolean);-- 布尔型不可以直接打印if v_boolean=true thenDbms_output.put_line('true');end if;end;/
CREATE OR REPLACE PROCEDURE pay_out_balance ( account_id_in IN accounts.id%TYPE)IS l_balance_remaining NUMBER;BEGIN LOOP l_balance_remaining := account_balance (account_id_in); IF l_balance_remaining < 1000 THEN EXIT; ELSE apply_balance (account_id_in, l_balance_remaining); END IF; END LOOP;END pay_out_balance;/
declarev1 number(6);v2 number(6); v3 number(6);beginv1 :=100;v2 :=200; declare v1 number(6); v4 number(6); begin v1:=110; v2:=210; v4:=300; dbms_output.put_line('inner v1 v2 v3:'||v1||' '||v2||' '||v4); end; v3 :=400; --dbms_output.put_line('outer v1 v2 v3:'||v1||' '||v2||' '||v3||' '||v4); dbms_output.put_line('outer v1 v2 v3:'||v1||' '||v2||' '||v3);end;/