Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Package Dependancy Order

Re: Package Dependancy Order

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 12 Nov 1998 15:45:12 GMT
Message-ID: <364d014d.8121798@192.86.155.100>


A copy of this was sent to Colin Woods <cwoods_at_talk21.com> (if that email address didn't require changing) On Wed, 11 Nov 1998 13:13:31 +0000, you wrote:

>Folks
>
>I have a database where I compile a large amount of packages.
>Unfortunately I haven't got the dependency right, with the result that I
>have a number of INVALID packages body's at the end.
>
>Currently I use the ALTER PACKAGE command or the
>DBMS_UTILITY.COMPILE_SCHEMA utility to resolve this problem.
>
>However I want to tidy my compile process. Is there command or utility
>that I can use which will list a users package dependency order.
>
>regards
>Colin Woods
>cwoods_at_talk21.com

Typically -- you should just be able to create all of your package SPECS -- and then all of your package bodies. Since bodies only depend on specs -- all of the bodies will be valid since they won't depend on other bodies (so their order does not matter) and since they must have a valid spec, any spec that is invalid (due to it depending on some other spec that wasn't yet created) will have been auto-compiled when the body compiled. The end result will be a clean schema....

Here is an example. We have 2 packages test_pkg1 and test_pkg2. Test_pkg1 relies (is dependent on) test_pkg2. We build test_pkg1 spec then test_pkg2 spec and then the bodies of each. The end result is a clean compile:

SQL> column status format a10
SQL> select object_type, object_name, status   2 from user_objects
  3 where status = 'INVALID'
  4 order by object_type, object_name
  5 /

no rows selected

SQL> create package test_pkg1
  2 as
  3 x test_pkg2.y%type;
  4
  4 procedure foo;
  5 end;
  6 /

Warning: Package created with compilation errors.

SQL> create package test_pkg2
  2 as
  3 y number;
  4
  4 procedure foo;
  5 end;
  6 /

Package created.

SQL>
SQL> create package body test_pkg1
  2 as
  3
  3 procedure foo is begin null; end;
  4
  4 end;
  5 /

Package body created.

SQL>
SQL> create package body test_pkg2
  2 as
  3
  3 procedure foo is begin null; end;
  4
  4 end;
  5 /

Package body created.

SQL> column status format a10
SQL> select object_type, object_name, status   2 from user_objects
  3 where status = 'INVALID'
  4 order by object_type, object_name
  5 /

no rows selected

You could use the view user_dependencies to try and figure out the right order but -- why bother? its pretty hard and might change over time...  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Nov 12 1998 - 09:45:12 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US