I agree with Niall. If one object is invalid, that object should be compiled
instead of compiling all. I want to add that intentionally invalidating an
object sometimes can be used to check for usage prior to dropping the object.
Some shops adopt the practice of renaming a table and dropping it some time
later, in case the table is still used by an infrequently run application. The
same idea can be applied to PL/SQL objects, except you can't rename them. But
you can execute dbms_utility.invalidate and later check the object status right
before dropping it. If the status changes to valid, you know an obscure program
had run the PL/SQL program during this monitoring period. If you compiled it,
you would get a false positive in this monitoring.
Yong
often there's an--
underlying reason why an object is invalid which recompilation won't fix
and therefore human intervention is required. In addition, the scope of
your solution recompile *all* invalid objects doesn't match the alert "
*this* object is invalid" - surely a better approach would be to attempt to
fix the particular object that is invalid.