Hi Frds,You may face a situation to compile invalid objects but it would be difficult to compiling one by one object.
To do in single step,we can use following anonymous block.
1)
Begin
For C1 IN(select a.object_name,a.object_type from User_Objects a where status='INVALID')
LOOP
IF C1.OBJECT_TYPE='PACKAGE BODY' THEN
EXECUTE IMMEDIATE 'ALTER PACKAGE '||C1.object_name||' COMPILE BODY';
ELSE
EXECUTE IMMEDIATE 'ALTER '||C1.OBJECT_TYPE||' '||C1.object_name||' COMPILE';
End If;
End Loop;
Exception
When Others then
Dbms_Output.put_line('Msg '||SQLERRM);
End;
Above script can be modified to compile specific object type i.e like synonym,view,package etc by using where clause.
If still don't want to execute above script then you can use below utility provided by Oracle to compile full schema.
2)
SQL > exec dbms_utility.compile_schema(schema => 'Schema Name');
Below one is one more simple method to compile full schema.
3)
SQL> utl_recomp.recomp_parallel('20',<schema name>);
To do in single step,we can use following anonymous block.
1)
Begin
For C1 IN(select a.object_name,a.object_type from User_Objects a where status='INVALID')
LOOP
IF C1.OBJECT_TYPE='PACKAGE BODY' THEN
EXECUTE IMMEDIATE 'ALTER PACKAGE '||C1.object_name||' COMPILE BODY';
ELSE
EXECUTE IMMEDIATE 'ALTER '||C1.OBJECT_TYPE||' '||C1.object_name||' COMPILE';
End If;
End Loop;
Exception
When Others then
Dbms_Output.put_line('Msg '||SQLERRM);
End;
Above script can be modified to compile specific object type i.e like synonym,view,package etc by using where clause.
If still don't want to execute above script then you can use below utility provided by Oracle to compile full schema.
2)
SQL > exec dbms_utility.compile_schema(schema => 'Schema Name');
Below one is one more simple method to compile full schema.
3)
SQL> utl_recomp.recomp_parallel('20',<schema name>);
No comments:
Post a Comment