DECLARE 
  s t_string_list := t_string_list();
BEGIN

FOR d IN 1..3 LOOP
SELECT
     decode( OBJECT_TYPE, 'PACKAGE BODY',
     'alter package ' || OWNER||'.'||OBJECT_NAME || ' compile body',
     'TYPE',
     'alter type ' || OWNER||'.'||OBJECT_NAME || ' compile',
     'TYPE BODY',
     'alter type ' || OWNER||'.'||OBJECT_NAME || ' compile body',
     'alter ' || OBJECT_TYPE || ' ' || OWNER||'.'||OBJECT_NAME || ' compile' ) 
     BULK COLLECT INTO s
FROM
     all_objects
WHERE (STATUS = 'INVALID') AND (OWNER = USER)
AND (OBJECT_TYPE in ( 'PACKAGE BODY', 'PACKAGE', 'FUNCTION', 'PROCEDURE',
                       'TRIGGER', 'TYPE', 'TYPE BODY', 'VIEW' ))
ORDER BY
     OBJECT_TYPE,
     OBJECT_NAME;

FOR a IN 1..s.count LOOP
BEGIN
EXECUTE IMMEDIATE s(a);
EXCEPTION
WHEN OTHERS THEN NULL;
END;
END LOOP;
s.delete;

END LOOP; 
  
END;
/
