3. 실행문 작성
A. Lexical Unit
B. 코드 주석처리
— 로 처리된 부분
C. PL/SQL 의 SQL 함수
EX)
set serveroutput on
declare
v_desc_size integer(5);
v_desc varchar2(10) := ‘Hello’;
begin
v_desc_size := length(v_desc);
dbms_output.put_line( v_desc_size);
end;
/
D. PL/SQL 표현식에서 시퀀스 사용
declare
v_new_id number;
begin
select my_seq.nextval into v_new_id from dual ;
END;
declare
v_new_id number;
begin
v_new_id := my_seq.NEXTVAL ;
END;
E. Data Type 변환
EX)
1)
declare
v_salary number(6) :=6000;
v_sal_hike varchar2(5) :=‘1000’;
v_total_salary v_salary%type;
begin
v_total_salary := v_salary + v_sal_hike;
dbms_output.put_line(v_total_salary);
end;
/
2)
declare
v_date_of_joining date := ‘02-Feb-2000’;
v_date2 date:= to_date(‘February 02, 2000’,
‘Month DD, YYYY’);
begin
dbms_output.put_line(v_date_of_joining);
dbms_output.put_line(v_date2);
end;
/
F. 중첩 블록
EX)
1)
declare
v_father_name varchar2(20) := ‘Patrick’;
v_date_birth date := ’20-Apr-1972’;
begin
declare
v_child_name varchar2(20) := ‘Mike’;
v_date_birth date := ‘12-Dec-2002’;
begin
dbms_output.put_line( ‘Father’’s Name : ‘ || v_father_name);
dbms_output.put_line( ‘Date of Birth : ‘ || v_date_birth);
dbms_output.put_line( ‘Child’’s Name : ‘ || v_child_name);
end;
dbms_output.put_line( ‘Date of Birth : ‘ || v_date_birth);
end;
/
2) 중첩 블록에 수식자 사용
begin <<outer>>
declare
v_father_name varchar2(20) := ‘Patrick’;
v_date_birth date := ’20-Apr-1972’;
begin
declare
v_child_name varchar2(20) := ‘Mike’;
v_date_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_birth);
dbms_output.put_line( ‘Child’’s Name : ‘ || v_child_name);
dbms_output.put_line( ‘Date of Birth : ‘ || v_date_birth);
end;
end;
end outer;
/
G. PL/SQL 의 연산자