How to show errors in sqlplus

2019-01-29 03:33发布

问题:

I would like to know how to show errors in sqlplus.

  1. try to compile a view

    alter view SYS.DBA_XML_SCHEMAS compile;

  2. I have the message :

    ERROR at line 1:
    
    ORA-04063 : view altered with compilation errors.
    
  3. I try :

    show errors;

  4. it says :

    No errors
    
  5. I try :

    show errors view SYS.DBA_XML_SCHEMAS
    
  6. it says :

    LINE/COL  ERROR
    
    0/0       ORA-00942 : table or view does not exist
    

If I could compile with errors, the view must exist or it would tell me that the view does not exist. I dont know how to display the compilation errors of the view

thank you

回答1:

You can query the dba_errors view, or the all_errors view, directly; the SQL*Plus show errors command seems to be a wrapper around that anyway.

select line, position, attribute, text
from dba_errors
where owner = 'SYS'
and type = 'VIEW'
and name = 'DBA_XML_SCHEMAS'
order by sequence;

But based on what show errors is telling you, that will just show the same thing, error "ORA-00942 : table or view does not exist" from line 0 position 0.

That doesn't make much sense, but internal views are sometimes strange things, and attempting to recompile one is probably not a good idea.

You might need to get your DBA to run utlrp.sql to recompile all invalid objects in the database. As with anything you think of doing under the SYS schema, that should be done with care; and only if selecting from the view still says it's invalid and failed recompilation.