Problem solve Get help with specific problems with your technologies, process and projects.

Compile all invalid objects including those with syntax errors

With this script, you can see not just invalid objects, but also those with syntax errors.

Here's how to compile all invalid objects, including these with syntax errors. It can by used for specific schemas or for whole databases.

In comparision with utlrp.sql you can:

  • specify the schema (user) in the statement "u.name"
  • see not just invalid objects, but also those with syntax errors

It can be used for development of specific schema, to simultaneously check for syntax errors and invalid objects. It was tested on Oracle 8.1.7.

select o.obj#, 
       'ALTER '                              || 
        decode (o.type#,   4, 'VIEW '     , 
                           7, 'PROCEDURE ', 
                           8, 'FUNCTION ' , 
                           9, 'PACKAGE '  , 
                          11, 'PACKAGE '  , 
                          12, 'TRIGGER '  , 
                          13, 'TYPE '     , 
                          14, 'TYPE '     , 
                                ' ')         || 
       '"'                                   || 
       u.name                                || 
       '"."'                                 || 
       o.name                                || 
       '" COMPILE '                          || 
       decode (o.type#,    9, 'SPECIFICATION', 
                          11, 'BODY', 
                          13, 'SPECIFICATION', 
                          14, 'BODY', 
                                ' ')         || 
       ';'     as COMPILE 
from  sys.obj$  o, 
      sys.user$ u 
where u.user# = o.owner# 
  and o.remoteowner is NULL 
  and o.status in (3,4,5,6)                     -- 3: possible syntax error 
  and o.type# in (4, 7, 8, 9, 11, 12, 13, 14)   
  and u.name = 'WRITE_YOUR_SCHEMA_HERE'         -- your schema 
order by o.obj#

 

Reader Feedback

John L. writes: Unless I am missing something, the title is misleading. I do not see anything in the code that would allow you to compile an invalid object that has a syntax error.

 

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our applications, SQL, database administration, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.


 

Dig Deeper on Oracle error messages

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close