/*
  SQL Query to generate a script to enable all disabled triggers
  and to compile all invalid objects
*/
SET PAGESIZE 0 LINESIZE 120 ECHO OFF FEEDBACK OFF HEADING OFF TERMOUT OFF
SPOOL fix.sql
SELECT 'ALTER '
|| DECODE(object_type,'PACKAGE BODY', 'PACKAGE', 'TYPE BODY', 'TYPE', object_type)
|| ' '
|| LOWER(object_name)
|| ' COMPILE '
|| DECODE(object_type, 'PACKAGE BODY', 'BODY;', ';')
FROM user_objects
WHERE status = 'INVALID'
ORDER BY DECODE(object_type,'PACKAGE BODY', 'ZZZZZ',object_type);
SELECT
'ALTER TRIGGER ' || LOWER(trigger_name) || ' ENABLE;'
FROM user_triggers
WHERE status <> 'ENABLED';
SELECT
'ALTER SYNONYM ' || SYNONYM_NAME || ' COMPILE;'
FROM user_synonyms;
SPOOL OFF
SET ECHO ON FEEDBACK ON HEADING ON TERMOUT ON
START fix
