select 'alter '||decode(object_type,'PACKAGE BODY','PACKAGE',object_type)||' '||owner||
       '.'||object_name||' compile'||decode(object_type,'PACKAGE BODY',' BODY',null)||';'
from dba_objects where status <> 'VALID' order by owner
/
