oracle pl/sql笔记
I 、Instoduction
1、Instoduction to pl/sql
1)pl/sql block Structure
declare
begin
--statements
exception
end;
2)Block Types
Anonymous
declare
begin
--statements
exception
end;
Procedure
Procedure name is
begin
--statements
exception
end;
Function
Function name return datatype is
begin
--statements
return value;
exception
end;
SQL> set serveroutput on; SQL> declare
|
2、Declaring PL/SQL Variables
1)Delimiters in String Literals
SQL> declare 2 v_event varchar2(15); 3 begin 4 v_event := q'! Father's day!'; 5 dbms_output.put_line('3rd Sunday in June is: '|| v_event); 6 v_event := q'[Mother's day]'; --或者两个‘ 7 dbms_output.put_line('2nd Sunday in May is: ' || v_event); 8 end; 9 / 3rd Sunday in June is: Father's day |
2、Using a Qualifier with Nested Blocks
begin <<outer>> declare v_father_name varchar2(20) :='Pitrick'; v_date_of_birth date := '10-apr-1985'; begin declare v_child_name varchar2(20) := 'nike'; v_date_of_birth date :='12-dec-2002'; begin dbms_output.put_line('Father''s name: ' || v_father_name); dbms_output.put_line('Date of Birth: ' || outer.v_date_of_birth); dbms_output.put_line('Child''s Name: ' || v_child_name); dbms_output.put_line('Date of Birth: ' || v_date_of_birth); end; end; end outer;
SQL> /
|