Create Or Replace ProcedureRecompile_schema Is V_type user_objects.object_type %Type; V_name user_objects.object_name %Type; V_stat user_objects.status %Type; CursorC_obj Is SelectBase From(SelectA. object_id Base , B. object_id REL FromUser_objects , User_objects B ,Sys. Dependency $ C WhereA. object_id = c.d _ OBJ # AndB. object_id = c.p _ OBJ # AndA. object_typeIn('Package ', 'Processure ', 'Function ', 'Package body ', -- 'View ', 'Trigger ') AndB. object_typeIn('Package ', 'Processure ', 'Function ', 'Package body ', -- 'View ', 'Trigger ') AndNotA. object_name = B. object_name) Objects Connect ByBase =PriorREL GroupByBase OrderBy Max(Level)Desc; Begin -- Loop through all objects in order of dependancy. ForC_rowInC_obj Loop -- Select the objects attributes (type, Name & status ). SelectObject_type , Object_name , Status IntoV_type , V_name , V_stat FromUser_objects WhereObject_id = c_row.base; -- If the object is invalid, recompile it. IfV_stat = 'invalid'Then Dbms_ddl.alter_compile (v_type,User, V_name ); End If; End Loop; -- Recompile all remaining invalid objects (all those without dependencies ). ForC_rowIn(SelectObject_type , Object_name FromUser_objects WhereStatus = 'invalid' AndObject_typeIn('Package ', 'Processure ', 'Function ', 'Trigger ', 'Package body ', -- 'View ', 'Trigger ')) Loop Dbms_ddl.alter_compile (c_row.object_type,User, C_row.object_name ); End Loop; EndRecompile_schema; Rem examples Rem 1. recompileAllObjects sequentially: RemExecuteUtl_recomp.recomp_serial (); Rem Rem 2. recompile objectsIn SchemaScott sequentially: RemExecuteUtl_recomp.recomp_serial ('Scott '); Rem Rem 3. recompileAllObjectsUsing4ParallelThreads: RemExecuteUtl_recomp.recomp_parallel (4 ); Rem Rem 4. recompile objectsIn SchemaJoeUsing The Number OfThreads Rem specifiedIn TheParamter job_queue_processes: RemExecuteUtl_recomp.recomp_parallel (Null, 'Job '); Rem Rem 5. recompileAllObjectsUsing2ParallelThreads, but allow Rem other applicationsTo Use TheJobQueueConcurrently: RemExecuteUtl_recomp.recomp_parallel (2,Null, Rem utl_recomp.share_job_queue ); Rem Rem 6.Restore TheJobQueue AfterA failureInRecomp_parallel: RemExecuteUtl_recomp.restore_job_queue (); |