Difference between revisions of "Script: Compile All Invalid Objects"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
-- alter object_type owner.object_name compile;
 
-- alter object_type owner.object_name compile;
 
-- ========================================================================================
 
-- ========================================================================================
SELECT 'alter ' || decode(object_type,'PACKAGE BODY','PACKAGE',object_type)  
+
SELECT 'alter ' || decode(owner,'PUBLIC','public ',' ') || decode(object_type,'PACKAGE BODY','PACKAGE','TYPE BODY','TYPE',object_type)  
|| ' ' || owner || '.' || object_name || ' compile '  
+
|| ' ' || decode(owner,'PUBLIC','',owner || '.') || object_name || ' compile '  
|| decode(object_type,'PACKAGE BODY','body','') || ';'
+
|| decode(object_type,'PACKAGE BODY','body','TYPE BODY','body','') || ';'
 
FROM dba_objects
 
FROM dba_objects
 
WHERE status <> 'VALID';
 
WHERE status <> 'VALID';
 
</pre>
 
</pre>
 +
 +
[[Category:Oracle_Scripts]]

Latest revision as of 07:45, 21 June 2012

-- ========================================================================================
-- 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';