9.8. Compilation Dependency

Concerning just packages, a specification must exist and compile without errors before the package body can compile.

9.8.1. Scenario 1

The following is a package specification and body. There is one procedure.

-- Filename PK_SPECIFICATION.SQL
CREATE OR REPLACE PACKAGE pk is
    PROCEDURE p1;
END pk;
/

-- Filename PK_BODY.SQL
CREATE OR REPLACE PACKAGE BODY pk is
    PROCEDURE p1 IS
    begin
        dbms_output.put_line('execute p1');
    END p1;
END pk;
/

Figure 9-5 illustrates the package PK and the visible procedure P1. Additionally, there is a second package, AX. An AX procedure uses the procedure P1.

Figure 9-5. Package Body Referencing Another Package.

The body of AX is dependent on the specification of PK. Specifically, the body ...

Get Programming Oracle® Triggers and Stored Procedures, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.