Compile all invalid objects including those with syntax errors

Compile all invalid objects including 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

    Requires Free Membership to View

    By submitting your registration information to SearchOracle.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchOracle.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

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.

This was first published in December 2003

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.