Nested package reference
SQL> CREATE TABLE EMP(
2 EMPNO NUMBER(4) NOT NULL,
3 ENAME VARCHAR2(10),
4 JOB VARCHAR2(9),
5 MGR NUMBER(4),
6 HIREDATE DATE,
7 SAL NUMBER(7, 2),
8 COMM NUMBER(7, 2),
9 DEPTNO NUMBER(2)
10 );
Table created.
SQL> create or replace package myPackage1 is
2 procedure P1; end;
3 /
Package created.
SQL> create or replace package body myPackage1 is
2 procedure P1 is
3 v_cnt number;
4 begin
5 select count(*) into v_cnt from emp;
6 end;
7 end;
8 /
Package body created.
SQL> create or replace package myPackage2 is procedure P2; end;
2 /
Package created.
SQL> create or replace package body myPackage2 is
2 procedure P2 is
3 begin
4 myPackage1.P1;
5 end;
6 end;
7 /
Package body created.
SQL> create or replace package myPackage3 is procedure P3; end;
2 /
Package created.
SQL> create or replace package body myPackage3 is
2 procedure P3 is
3 begin
4 myPackage2.P2;
5 end;
6 end;
7 /
Package body created.
SQL> create or replace package myPackage4 is
2 procedure P4; end;
3 /
Package created.
SQL> create or replace package body myPackage4 is
2 procedure P4 is
3 begin
4 myPackage3.P3;
5 end;
6 end;
7 /
Package body created.
SQL> create or replace package body myPackage1 is
2 procedure P1 is
3 v_cnt number;
4 begin
5 select count(*) into v_cnt from emp where empno > 0;
6 end;
7 end;
8 /
Package body created.
SQL>
SQL> select object_name, object_type, status
2 from user_objects
3 where object_name in ('MYPACKAGE1','MYPACKAGE2','MYPACKAGE3','MYPACKAGE4');
no rows selected
SQL>
SQL>
SQL> drop table emp;
Table dropped.
Related examples in the same category