Script: Compile All Invalid Objects

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
-- ========================================================================================
-- Compile all Invalid objects
--       PACKAGE BODY:
--			alter package owner.package_body_name compile BODY;
--
--	   All Others:
--			alter object_type owner.object_name compile;
-- ========================================================================================
SELECT 'alter ' || decode(owner,'PUBLIC','public ',' ') || decode(object_type,'PACKAGE BODY','PACKAGE','TYPE BODY','TYPE',object_type) 
|| ' ' || decode(owner,'PUBLIC','',owner || '.') || object_name || ' compile ' 
|| decode(object_type,'PACKAGE BODY','body','TYPE BODY','body','') || ';'
FROM dba_objects
WHERE status <> 'VALID';