If you are really dealing with only PL / SQL packages, you do not need to sweat the build order. First create all the package specifications. Then you can expand all the package bodies and they will compile because their dependencies are package specifications.
If you have some package specifications that depend on other specifications β if you have packages that declare, say, constants, subtypes, or link pointers that are used in the signatures of packed procedures β then you need to collect these specification packages in the first turn. But there should be enough of them so that you can organize them in the script assembly manually.
change
It looks like they will do incremental AND "clean sweep" builds, so the assembly order will be of greatest importance when they clean the environment and restore it.
This does not change anything.
Here is an extended example. I have a scheme with three packages ....
SQL> select object_name, object_type, status 2 from user_objects 3 order by 1, 2 4 / OBJECT_NAME OBJECT_TYPE STATUS --------------- --------------- ------- PKG1 PACKAGE VALID PKG1 PACKAGE BODY VALID PKG2 PACKAGE VALID PKG2 PACKAGE BODY VALID PKG3 PACKAGE VALID PKG3 PACKAGE BODY VALID 6 rows selected. SQL>
Interestingly, the procedure in PKG1 calls the procedure from PKG2, the procedure in PKG2 calls the procedure from PKG3, and the procedure in PKG3 calls the procedure from PKG1.
Q. How does this cyclic dependency work?
A. This is not circular dependence ....
SQL> select name, type, referenced_name, referenced_type 2 from user_dependencies 3 where referenced_owner = user 4 / NAME TYPE REFERENCED_NAME REFERENCED_TYPE --------------- --------------- --------------- --------------- PKG1 PACKAGE BODY PKG1 PACKAGE PKG1 PACKAGE BODY PKG2 PACKAGE PKG2 PACKAGE BODY PKG2 PACKAGE PKG2 PACKAGE BODY PKG3 PACKAGE PKG3 PACKAGE BODY PKG3 PACKAGE PKG3 PACKAGE BODY PKG1 PACKAGE 6 rows selected. SQL>
All dependent objects are package bodies, all reference objects are packed specifications. Therefore, if I do not create a circuit, it really does not matter which order I use. First we trash ...
SQL> drop package pkg1 2 / Package dropped. SQL> drop package pkg2 2 / Package dropped. SQL> drop package pkg3 2 / Package dropped. SQL>
Then we rebuild ...
SQL> create or replace package pkg3 is 2 procedure p5; 3 procedure p6; 4 end pkg3; 5 / Package created. SQL> create or replace package pkg2 is 2 procedure p3; 3 procedure p4; 4 end pkg2; 5 / Package created. SQL> create or replace package pkg1 is 2 procedure p1; 3 procedure p2; 4 end pkg1; 5 / Package created. SQL> create or replace package body pkg2 is 2 procedure p3 is 3 begin 4 pkg3.p5; 5 end p3; 6 procedure p4 is 7 begin 8 dbms_output.put_line('PKG2.P4'); 9 end p4; 10 end pkg2; 11 / Package body created. SQL> create or replace package body pkg3 is 2 procedure p5 is 3 begin 4 dbms_output.put_line('PKG3.P5'); 5 end p5; 6 procedure p6 is 7 begin 8 pkg1.p1; 9 end p6; 10 end pkg3; 11 / Package body created. SQL> create or replace package body pkg1 is 2 procedure p1 is 3 begin 4 dbms_output.put_line('PKG1.P1'); 5 end p1; 6 procedure p2 is 7 begin 8 pkg2.p4; 9 end p2; 10 end pkg1; 11 / Package body created. SQL>
The order of the individual objects does not matter. Just create package specifications in front of the package body. Although even this does not really matter ...
SQL> create or replace package pkg4 is 2 procedure p7; 3 end pkg4; 4 / Package created. SQL> create or replace package body pkg4 is 2 procedure p7 is 3 begin 4 dbms_output.put_line('PKG4.P7::'||constants_pkg.whatever); 5 end p7; 6 end pkg4; 7 / Warning: Package Body created with compilation errors. SQL> show errors Errors for PACKAGE BODY PKG4: LINE/COL ERROR -------- ----------------------------------------------------------------- 4/9 PL/SQL: Statement ignored 4/43 PLS-00201: identifier 'CONSTANTS_PKG.WHATEVER' must be declared SQL>
PKG4 is INVALID because we have not built CONSTANTS_PKG yet.
SQL> create or replace package constants_pkg is 2 whatever constant varchar2(20) := 'WHATEVER'; 3 end constants_pkg; 4 / Package created. SQL> select object_name, object_type, status 2 from user_objects 3 where status != 'VALID' 4 order by 1, 2 5 / OBJECT_NAME OBJECT_TYPE STATUS --------------- --------------- ------- PKG4 PACKAGE BODY INVALID SQL> SQL> set serveroutput on size unlimited SQL> exec pkg4.p7 PKG4.P7::WHATEVER PL/SQL procedure successfully completed. SQL> select object_name, object_type, status 2 from user_objects 3 where status != 'VALID' 4 order by 1, 2 5 / no rows selected SQL>
Everything that is built using CREATE OR REPLACE is always created, it is simply marked as INVALID if there are errors. As soon as we execute it, directly or indirectly, the database compiles it for us. So the order doesn't matter. This is actually not the case.
If the idea of ββcompleting the assembly with invalid objects concerns you - and I have some sympathy for this, we are told not to live with broken windows - you can use the utlrp script or the UTL_RECOMP package in 11g; any approach requires a SYSDBA account.
change 2
The process is based on the assembly tool created by the seller of the product with which we integrate, therefore the only inputs I can give the assembly process is a list of files in the order in which they should be built-in. If there is a compiler error, the build tool does not work, we have to manually send a request for a new build.
This is a political issue, not a technical one. This does not mean that political problems cannot be solved with a technical solution, namely, that a technical correction is not the best tool for work. Good luck.