What will happen if we compile a Oracle package with different name?

979 views Asked by At

I have a sql package that contains many stored procedures.

create or replace package body My_Pck is
    /** Package started **/

    /** Procedure 1 **/
    procedure one() as
    begin
    end;

    /** Procedure 2 **/
    procedure one() as
    begin
    end;
My_Pck end;

The question is if I compile this package with different name what will happen? The other procedures that are in the new package will override the original procedure? I searched a lot but din't get the suitable ans.

Any suggestion will be very helpful.

1

There are 1 answers

0
sandi On

Here you need to understand a point.

Package is basically collection of procedures, functions , etc. The procedures which are defined inside a package, can not be called independent without specifying qualifier package name. These procedures are always used as package.procedure.

lets consider your package. You can call the procedure like My_Pck.one.

create or replace package body My_Pck is
/** Package started **/

/** Procedure 1 **/
procedure one() as
begin
end;

/** Procedure 2 **/
procedure one() as
begin
end;
My_Pck end;

if you compile package with different name like below, then you need to call procedure as my_pck2.one.

create or replace package body My_Pck2 is
/** Package started **/

/** Procedure 1 **/
procedure one() as
begin
end;

/** Procedure 2 **/
procedure one() as
begin
end;
My_Pck end;

Thanks