Debug and Validate Invalid Objects (Doc ID 300056.1)

5

Click here to load reader

description

Como depurar objetos invalidos en Oracle

Transcript of Debug and Validate Invalid Objects (Doc ID 300056.1)

  • Debug and Validate Invalid Objects (Doc ID 300056.1)

    In this Document

    Purpose

    Scope

    Details

    A) Find Invalid Objects:

    B) Try Manual method of validation:

    C) How to Find the Compilation Errors:

    D) Find Dependencies & Debug error message:

    E) Recreate sys/system objects using scripts

    F) Standard scripts for automatic recompilation of invalid objects

    More debugging

    G)Enable 10046 tracing and upload trace.

    H) Errorstack for specific errors:

    Information required by Support

    References

    APPLIES TO:

    Oracle Database - Enterprise Edition - Version 8.1.7.4 to 11.2.0.3 [Release 8.1.7 to 11.2]

    Information in this document applies to any platform.

    Checked for relevance on 30-Jul-2012

    PURPOSE

    This document is intended to help customers in resolving invalid database objects problem.

    SCOPE

    This can be used to resolve / generate more debug information and contact support for resolving the problem.

    This note covers basic database objects like views,procedures and packages.

    It does not deal much in detail with invalid java objects. Articles referred in References section can help in resolving invalid JAVA objects.

    DETAILS

    A) Find Invalid Objects:

    1.To Find the number of invalid objects :

    select count(*) from dba_objects where status='INVALID';

    select owner,object_type,count(*) from dba_objects where status='INVALID' group by owner,object_type;

    2.To identify the object name and their types and owner:

    select owner, object_name,object_type from dba_objects where status ='INVALID';

    B) Try Manual method of validation:

    Alter procedure . compile;

    Document Display https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-stat...

    1 de 5 03/06/2015 04:36 a.m.

  • Alter function . compile;

    Alter view . compile;

    Alter package . compile;

    Alter package . compile body;

    Alter materialized view . Compile;

    In case you have lots of invalid objects, you can generate scripts that will generate the sqls for compiling the invalid objects :

    In sqlplus connect as sys:

    set heading off

    spool compileinvalid.sql

    select 'alter '||object_type|| ' ' || owner ||'.'||object_name || ' compile;' from dba_objects where status='INVALID';

    spool off

    Then run compileinvalid.sql in sqlplus prompt as sys user.

    To compile invalid package body use:

    alter package compile body;

    C) How to Find the Compilation Errors:

    If any of compile statement returns warning of form:

    Warning: Procedure created with compilation errors.

    Warning: View created with compilation errors.

    Warning: Function created with compilation errors.

    Warning: Package created with compilation errors.

    C.1)From sqlplus

    Type in sqlplus

    Show errors

    Immediately following the failing alter .. compile statement. This should show the cause of compilation error.

    Note the error number and the error description and resolve the error.

    C.2) From data dictionary view : dba_errors

    If show errors returns no errors, then check in dba_errors :

    Select text from dba_errors where name ='' and owner ='';

    The above select would give the list of error messages that led to compilation error.

    C.3) Compilation errors in x_$* views.

    eg: alter view x_$bh compile;

    warning : view altered with compilation errors.

    These views or dependent views are customized ones (user created views) and are generally created by third party applications or

    application developers. The 3rd party scripts may create views on X$ tables and Oracle does not guarantee that X$ tables are the same

    between releases. These x_$ views do not compile because they are based on x$ tables which might have changed (columns dropped)

    Document Display https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-stat...

    2 de 5 03/06/2015 04:36 a.m.

  • and/or do not exist (X$ table dropped) in the database post upgradation.

    Its not recommended to have views based on X$ tables and if done, it is recommended to drop such views prior to database upgrade. You

    can contact the developers or 3rd party vendors for alternate scripts. Refer Note 361757.1 for details.

    D) Find Dependencies & Debug error message:

    If the error message is generic like ,table or view does not exist/no columns in table ,then to debug further we need to find all the objectson

    which the invalid object is dependent on.

    We can get the information using the following query:

    Select referenced_owner, referenced_name,referenced_type from dba_dependencies where name='' and type

    ='' and owner ='';

    Check for the existence of the dependent objects and their status by querying dba_objects .

    E) Recreate sys/system objects using scripts

    If they are sys/system related packages/procedures/views/functions,you can recreate them using the scripts in $ORACLE_HOME/rdbms

    /admin.

    To find the creation scripts ,say for example dbms_shared_pool

    cd $ORACLE_HOME/rdbms/admin grep -i 'create or replace package dbms_shared_pool' *.sql

    P.S: You may need to change the the command as below since not all scripts are .sql files.

    cd $ORACLE_HOME/rdbms/admin grep -i 'create or replace package dbms_shared_pool' *.*

    Then run the script in sqlplus as 'sys' user.

    F) Standard scripts for automatic recompilation of invalid objects

    In addition to manual recompilation,you have scripts to validate packages/sub programs

    The script has to be run in restricted mode of database as SYS user. Note the number of invalid objects and spool the invalid objects list

    before and after running these scripts.

    More debugging

    In certain cases, the structure of base table could have changed from one version to another version and this could be the cause of invalid

    objects. This can be seen after upgrade. The following tracing would help in debugging such cases:

    G)Enable 10046 tracing and upload trace.

    If running utlrp.sql and manual method of compilation fails and still unable to solve the problem by using debugging steps in C,D,E sections

    then :

    Alter session set events '10046 trace name context forever,level 12'

    Alter procedure compile;

    Exit session.

    Check in user_dump_dest for trace file generated. Upload this to Oracle Support for further analysis.

    H) Errorstack for specific errors:

    If you find any specific errors ,you may also get an error stack:

    Alter session set events 'nnn trace name errorstack level 3';

    nnn=> Error number

    Document Display https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-stat...

    3 de 5 03/06/2015 04:36 a.m.

  • this will also generate trace in user_dump_dest.

    For example,say you get Ora-00942 as one of the errors:

    Then you have to set errorstack :

    Alter session set events '942 trace name errorstack level 3';

    Information required by Support

    If you are unable to resolve the problem still,then please contact support with the following details:

    1.Invalid objects info created by following script.

    set pages 1000set lines 120col owner format a30col object_name format a30col object_type format a30col comp_id format a20col comp_name format a40col version format a10col status format a15col dbname format a15spool INVALID_OBJECTS_AND_REGISTRY_INFO.lstPROMPT DATABASE NAMEPROMPT =============select sys_context('USERENV','DB_NAME') DBNAME from dual;PROMPT COUNT OF INVALID OBJECTSPROMPT ========================select count(*) from dba_objects where status='INVALID';PROMPT INVALID OBJECTS GROUPED BY OBJECT TYPE AND OWNERPROMPT ================================================select owner,object_type,count(*) from dba_objects where status='INVALID' group by owner,object_type;PROMPT DBA_REGISTRY CONTENTS (VIEW DOES NOT EXISIT IN VERSIONS < 9.2.0)PROMPT ================================================================select comp_id,comp_name,version,status from dba_registry;spool offspool INVALID_OBJECTS.lstPROMPT LIST OF INVALID OBJECTSPROMPT =======================select owner,object_name,object_type from dba_objects where status='INVALID';spool off

    The above script is uploaded as check_invalids.sql to this note as an attachment.

    Run this sql file as sys user and upload the following spool files created in the current working directory:

    INVALID_OBJECTS_AND_REGISTRY_INFO.lst

    INVALID_OBJECTS.lst

    2.Trace files generated in Steps G & H.

    3.List of dependent objects for every invalid object:

    Select referenced_owner, referenced_name,referenced_type from dba_dependencies where name='' and type

    ='' and owner ='';

    4.Error messages obtained from methods suggested in Step C.

    REFERENCES

    NOTE:752783.1 - Data Dictionary Objects Invalid after Running catalog.sql, catproc.sql, utlrp.sql or catpatch.sql

    BUG:2584802 - CATPROC SHOWS UP AS INVALID IN THE DBA_REGISTRY VIEW

    NOTE:209870.1 - How to Reload the JVM in 9.2.0.X

    NOTE:103536.1 - LoadJava Utility uploading Java files as Invalid

    NOTE:106206.1 - ORA-04068 Errors From User-Written And Oracle Packages

    Document Display https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-stat...

    4 de 5 03/06/2015 04:36 a.m.

  • NOTE:1292089.1 - Master Note for Oracle XML Database (XDB) Install / Deinstall

    NOTE:175472.1 - How to Reload the JVM in 8.1.7.X

    Didn't find what you are looking for?

    Document Display https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-stat...

    5 de 5 03/06/2015 04:36 a.m.