▣ Package 프로시저와 함수들의 집합, oop에서의 overloading지원, return값 유무에 대한 overloading
SQL> create or replace package myPackage
2 is
3 procedure gugu(dan number);
4 procedure print(st varchar2);
5 end;
6 /
Package created.
SQL> create or replace package body myPackage
2 is
3 procedure gugu(dan number) as
4 begin
5 for i in 1..9 loop
6 dbms_output.put_line(dan || 'x' || i || '=' || dan*i);
7 end loop;
8 end;
9 procedure print(st varchar2)
10 as
11 begin
12 dbms_output.put_line(st);
13 end;
14 end;
15 /
Package body created.
SQL> exec myPackage.gugu(3);
3x1=3
3x2=6
3x3=9
3x4=12
3x5=15
3x6=18
3x7=21
3x8=24
3x9=27
PL/SQL procedure successfully completed.
SQL> exec myPackage.print('aaa');
aaa
PL/SQL procedure successfully completed.
실제로 구현할 때는 Header와 Body가 한 파일(myPackage)에 들어간다.(마지막라인에는 실행부(exec)를 사용하여 확인할 수 있다.)
create or replace package myPackage
is
procedure gugu(dan number);
procedure print(st varchar2);
end;
/
create or replace package body myPackage
is
procedure gugu(dan number)as
begin
for i in 1..9 loop
dbms_output.put_line(dan || 'x' || i || '=' || dan*i);
end loop;
end;
procedure print(st varchar2)
as
begin
dbms_output.put_line(st);
end;
end;
/
exec myPackage.gugu(3);
exec myPackage.print('a');
댓글 없음:
댓글 쓰기