Operations such as upgrades, patches and DDL changes can invalidate schema objects.
These objects are re-validated by on-demand automatic recompilation if they don't have compilation errors. But it may take a significant time, so it is always better to make them compiled before they are called.
You can identify the invalid objects as below.
Method 1
If the objects are in small number you can compile by manual method as below.
Method 2Use the supplied package procedure DBMS_UTILITY.COMPILE_SCHEMA. EXECUTE
DBMS_UTILITY.COMPILE_SCHEMA(schema_name);
Recompiles all stored packages, procedures and functions in the specified schema. Objects are compiled in dependency order.
Method 3
These objects are re-validated by on-demand automatic recompilation if they don't have compilation errors. But it may take a significant time, so it is always better to make them compiled before they are called.
You can identify the invalid objects as below.
SELECT owner,
object_type,
object_name,
status
FROM dba_objects
WHERE status = 'INVALID'
ORDER BY owner, object_type, object_name;
Method 1
If the objects are in small number you can compile by manual method as below.
ALTER PACKAGE myPkg COMPILE;
ALTER PACKAGE myPkg COMPILE BODY;
Use the type of object i.e; PROCEDURE, FUNCTION, TRIGGER, VIEW with alter.
OR
EXEC DBMS_DDL.alter_compile('PACKAGE', 'MYSCHEMA', 'MYPKG');
Use the type of object i.e; PROCEDURE, FUNCTION, TRIGGER, VIEW for first parameter.
Method 2Use the supplied package procedure DBMS_UTILITY.COMPILE_SCHEMA. EXECUTE
DBMS_UTILITY.COMPILE_SCHEMA(schema_name);
Recompiles all stored packages, procedures and functions in the specified schema. Objects are compiled in dependency order.
Method 3
utlrp.sql and utlprp.sql
The utlrp.sql and utlprp.sql scripts are provided by Oracle to recompile all invalid objects in the database. They are typically run after major database changes such as upgrades or patches. They are located in the $ORACLE_HOME/rdbms/admin directory and provide a wrapper on the
UTL_RECOMP
package. The utlrp.sql script simply calls the utlprp.sql script with a command line parameter of "0". The utlprp.sql accepts a single integer parameter that indicates the level of parallelism as follows.- 0 - The level of parallelism is derived based on the CPU_COUNT parameter.
- 1 - The recompilation is run serially, one object at a time.
- N - The recompilation is run in parallel with "N" number of threads.
Both scripts must be run as the SYS user, or another user with SYSDBA, to work correctly.
No comments:
Post a Comment