select 'alter ' || decode(object_type, 'PACKAGE BODY', 'PACKAGE', object_type) || ' ' || owner || '.' || object_name || ' compile' || decode(object_type, 'PACKAGE BODY', ' body;', ';') from dba_objects where status='INVALID' order by owner, decode(object_type, 'PACKAGE BODY', 'AAA', 'PACKAGE', 'AAB', substr(object_type, 1, 3)) desc, object_name;