2009년 8월 16일 일요일

Package - 2

▣ Package Overloading : 프로시져 명이 같아도 Argument의 수에 따라 실행되는 Procedure가 다르다.

create or replace package myPackage

is

        procedure gugu;

        procedure gugu(dan number);

        procedure gugu(danStart number,danEnd number);

        procedure print(st varchar2);

        function gugu(dan number) return varchar2;

end;

/

create or replace package body myPackage

is

        function gugu(dan number) return varchar2

        as

                theString varchar2(2000) :='';

        begin

                for i in 1..9 loop

                        theString := theString || ',' || dan || 'X' ||i|| '=' || dan*i;

                end loop;

                return theString;

        end;

        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 gugu(danStart number,danEnd number) as

        begin

                for i in danStart..danEnd loop

                        gugu(i);

                end loop;

        end;

        procedure gugu as

        begin

                gugu(2,9);

                 end;

        procedure print(st varchar2)

        as

        begin

              dbms_output.put_line(st);

        end;

end;

/

댓글 없음:

댓글 쓰기