Link to home
Start Free TrialLog in
Avatar of suhinrasheed
suhinrasheed

asked on

Compiling Oracle objects in right order

Hi

I have a scenario like i have around 100 invalid objects in my system and i need to recompile them in one shot.
Is there any method by which this can be done with a condition that objects should be recompiled in a manner that..compilation of one object should not invalidate any other object in my database.

Avatar of prasanthi_k
prasanthi_k

Here is a script that compiles all invalid objects...
If there are any links between 2 objects, then 1st object can invalidate the second object. Otherwise validating an object will not make any other object invalid.

set heading off
set feedback off
spool x.dat
select 'alter ' || decode(object_type,'PACKAGE
BODY','PACKAGE',object_type)
|| ' ' || object_name || ' compile '  ||
decode(object_type,'PACKAGE BODY',' body;',';')  from user_objects
where object_type in ('FUNCTION','PACKAGE','PACKAGE
BODY','PROCEDURE','TRIGGER','VIEW')
and status = 'INVALID'
order by object_type , object_name;
spool off
 
set heading on
set feedback on
@x.dat  

Avatar of suhinrasheed

ASKER

What did yu mean by anylinks between 2 objects?
ASKER CERTIFIED SOLUTION
Avatar of sonicefu
sonicefu
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Suppose 1 procedure calls another procedure in its code.
Suppose 2nd procedure has some problem (for eg: column names written there are modified later in the table) and is not compiled, then automatically the 1st procedure is also invalidated.
Prashanth ..so i would prefer a script which takes care of all such scenarios you mentioned before.

That is my if my recompilation script is validating package 2 and during that recopilation of package 2..package 1 which was recompiled before becomes invalidated..i want my script to handle such a scenario and validate package1

So the compilation script should work in such a manner that objects are validated in the corect order
As far as I know such a script is not possible...

See these scenarios for example :

1. Package-1 has a column name 'Employee_name' in its code from table 'Employee' and is a valid package. On the object 'Employee' the column name is altered as 'Emp_name' instead of 'Employee_name'

Now Package-1 becomes 'INVALID'. whether it is compiled before table 'Employee' or after that. It can be compiled properly only when the column name in its code is changed accordingly as in the table... (This is just an example, the problem behind the object not getting validated can be anything that needs to be found...)

2. Package-2 calls a function in 'Package-1'. Now as 'Package-1' is INVALID, in what ever order it is compiled 'Package-2' should become 'INVALID' as it has got a problem. So irrespective of the order, the Invalid packages cannot be made 'VALID' unless the issue with them is corrected.
but i have seen scenarios in whch say i had to recompile a package and once i recompile it some of the dependent objects becomes invalid,athough these dependent objects are recompiled and validated automatically by oracle the next time they are invoked...My qstn is it not possible to do that recompilation of all dependent objects the same time the base object is recompiled
What is the current method you are following to compile the package?
Try following the above given scripts that will compile all the objects at a shot...
Prashanth will the above script ensure that the objects are recompiled in the correct manner
Sonice can you give me some brief witten explanation what your script exactly does.. i mean part by part
Have you used UTLRP?
my code gets invalid package, package body, functions and procedure names and then compile them all in the following order
1. PACKAGE
2. PACKAGE BODY
3. Functions and procedures
Forced accept.

Computer101
EE Admin