ed pack_java.sql
create or replace package pack_java
is
procedure print_avg_sal;
procedure p1 (p_empno number);
procedure p1 (p_empno varchar2);
end;
/
ed pack_java_body.sql
create or replace package body pack_java
is
private_v_avg_sal number := 0;
function f_emp_avg_sal return number; -- forward declaration
procedure p1 (p_empno number) -- overloading
is
v_sal number;
begin
select sal into v_sal
from emp
where empno = p_empno;
if v_sal > f_emp_avg_sal then
p('괜찮은데!');
end if;
end;
procedure p1 (p_empno varchar2) -- overloading
is
begin
p('잘못된 데이터 타입입니다.');
end;
function f_emp_avg_sal return number
is
begin
return private_v_avg_sal;
end;
procedure print_avg_sal
is
begin
p(private_v_avg_sal);
end;
begin -- initialization block (cf.one-time only procedure)
select avg(sal) into private_v_avg_sal
from emp;
end;
/
select distinct name, type
from user_source
where type like 'PACKAGE%'
order by type;
exec pack_java.print_avg_sal
exec pack_java.p1(7788)
exec pack_java.p1(7900)
exec pack_java.p1('7788')
col name format a15
col text format a80
select name, type, text
from user_source
where name = 'PACK_JAVA';
==> 패키지 본문의 소스가 다 공개됩니다
exit
C:\Documents and Settings\user\ora_java>wrap iname=pack_java_body.sql
PL/SQL Wrapper: Release 10.2.0.1.0- Production on 목 2월 23 14:46:09 2012
Copyright (c) 1993, 2004, Oracle. All rights reserved.
Processing pack_java_body.sql to pack_java_body.plb
C:\Documents and Settings\user\ora_java>more pack_java.sql
C:\Documents and Settings\user\ora_java>more pack_java_body.plb
create or replace package body pack_java wrapped
a000000
34e
abcd
abcd
abcd
........
jMJv
cf.) CALL SQL statement
exec p('오라클')
call p('오라클'); --> SQL 문이므로 ;을 반드시 붙여주어야 합니다.
'Oracle > PL/SQL' 카테고리의 다른 글
15일차 Chapter 6. Native Dynamic SQL & DBMS_SQL (0) | 2012.04.24 |
---|---|
15일차 Chapter 5. Oracle-Supplied Packages, DBMS_SCHEDULER (0) | 2012.04.24 |
15일차 # 4-8: Forward Declaration (0) | 2012.04.24 |
15일차 # 4-7 (0) | 2012.04.24 |
15일차 Chapter 4 - Packages II # 4-3 (0) | 2012.04.24 |