Oracle Compile 编译无效对象(ORA-04063: package body

使用AUTOTRACE 前要做好准备工作

创建角色Plustrace
SQL>        @?/sqlplus/admin/plustrce.sql
将Plustrace角色授于要执行AUTOTRACE的用户
SQL>        grant plustrace to sst;
----------------------------------------------------以上用sys身份执行

设置启用AUTOTRACE
SQL>        set autotrace on(输出结果+执行计划+统计信息)
不显示语句的执行结果
SQL>        set autotrace traceonly(执行计划+统计信息)
只显示执行计划
SQL>        set autotrace traceonly explain(执行计划)

Applies to:
Oracle Server - Enterprise Edition - Version: 10.1.0.5.0
This problem can occur on any platform.
Symptoms:
The issue is that the following error was raised :
ORA-00600: internal error code, arguments: [kesutlGetBindValue-2], [], [], [], [], [], [], []
The recent changes was the :
Migration from 10.1.0.5.0 database control to Grid Control Agent v10.2.0.3.0
What was runing at this moment of the error occurance was :
The attempt to run SQL Tuning Advisor from Grid Control

Cause:
Possibly invalid objects in the database.
As the issue here was to try to use these packages and then failed:
SYS.DBMS_SQLTUNE_INTERNAL
body SYS.PRVT_ADVISOR
body SYS.DBMS_ADVISOR
body SYS.DBMS_SQLTUNE
And as mentioned with the recent changes was the migration.

Solution:
1. fixup
1). connect to the database as sysdba:
sqlplus "/ as sysdba"
2). shutdown immediate
3). startup migrate
4). @?/rdbms/admin/catalog.sql
5). @?/rdbms/admin/catproc.sql
6). @?/rdbms/admin/utlrp.sql
7). shutdown immediate
8). startup

SELECT UNIQUE OBJECT_TYPE FROM ALL_objects where status = 'INVALID';
select 'ALTER ' || OBJECT_TYPE || ' '||owner||'.' || OBJECT_NAME || ' COMPILE;'
from  all_objects where  status = 'INVALID'
and  object_type in ('PACKAGE','FUNCTION','PROCEDURE', 'TABLE', 'VIEW', 'SEQUENCE', 'TRIGGER');
 
   
  SELECT * from dba_users;
  select 'ALTER PACKAGE ' || OWNER||'.'|| OBJECT_NAME || ' COMPILE body;'
from ALL_objects where status = 'INVALID' and object_type in ('PACKAGE BODY');
SELECT UNIQUE OBJECT_TYPE FROM ALL_OBJECTS;

2. Verify that the status of the CATPROC :
SQL> col comp_id format a10
SQL> col comp_name format a30
SQL> col version format a10
SQL> select comp_id, comp_name, status, version from dba_registry;

and the status of the other objects:
SQL> col object_name format a30
SQL> col owner format a15
SQL> select object_name, owner, object_type, status from dba_objects
where status = 'INVALID';

本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

2-If they are invalid please do the following:
To validate the invalid objects
1)-Please run the utlrp.sql script to try and validate the invalid packages, then check if they are valid or still invalid.
2 )-If the objects are still invalid after running the utlrp.sql script then run catalog.sql and catproc.sql and then run utlrp.sql
   a) Startup restrict or startup migrate.
   b) run catalog.sql
   c) run catproc.sql
   d) run utlrp.sql
3 )-Requery for the invalid objects again.
select owner,object_type,object_name from dba_objects where status='INVALID' ;
4 )-If they are still invalid please try to validate them manually using the below:
Try Manual method of validation:
Alter procedure <owner>.<procedure_name> compile;
Alter function <owner>.<function_name> compile;
Alter view <owner>.<view_name> compile;
Alter package <owner>.<package_name> compile;
Alter package <owner>.<package_name> compile body;
Alter materialized view <owner>.<Package_name> 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
ORA-06512: at "PS_SYSTEM.ROW_VALIDATOR_T", line 912
ORA-06512: at "PS_SYSTEM.ROW_VALIDATOR_T", line 924
ORA-06512: at "WORKORDER.INVENTORY_UTL", line 1260
select owner,object_name,object_type,status from all_objects where object_name='ROW_VALIDATOR_T' and owner='PS_SYSTEM';
OWNER                          OBJECT_NAME                        OBJECT_TYPE       STATUS
------------------------------ ------------------------------ ------------------- -------
PS_SYSTEM                      ROW_VALIDATOR_T           TYPE                      VALID
PS_SYSTEM                      ROW_VALIDATOR_T          TYPE BODY           VALID

SQL> select owner,object_name,object_type,status from all_objects where object_name='INVENTORY_UTL' and owner='WORKORDER'
 2  ;
OWNER                             OBJECT_NAME                     OBJECT_TYPE          STATUS
------------------------------ ------------------------------ -------------------      -------
WORKORDER                      INVENTORY_UTL           PACKAGE                  VALID
WORKORDER                      INVENTORY_UTL           PACKAGE BODY       VALID

Then run compileinvalid.sql in sqlplus prompt as sys user..
To compile invalid package body use:
alter package <package_name> compile body;

5 )-Also you could do the following  Note 100419.1  SCRIPT: VALIDATE.SQL to ANALYZE VALIDATE
STRUCTURE objects in a Tablespace
Please go through the above action plan and i will be waiting for your update.
6 )-Please make sure that these packages are valid:
SYS.DBMS_SQLTUNE_INTERNAL
body SYS.PRVT_ADVISOR
body SYS.DBMS_ADVISOR
body SYS.DBMS_SQLTUNE

References
Note 100419.1 - SCRIPT: VALIDATE.SQL to ANALYZE .. VALIDATE STRUCTURE objects in a Tablespace

alter PACKAGE BODY SYS.DBMS_XPLAN body compile;
alter PACKAGE BODY SYS.DBMS_SQLTUNE_INTERNAL body compile;
alter SYNONYM PUBLIC.HHLINEOR compile;
alter SYNONYM PUBLIC.HHNEIGHBOUR compile;
alter SYNONYM PUBLIC.HHLINEPS compile;
alter SYNONYM PUBLIC.HHIDROWS compile;
alter SYNONYM PUBLIC.HHIDLROWS compile;
alter SYNONYM PUBLIC.HHBITS compile;

---------无效索引查询 'INVALID INDEXES'

select s2.owner, s2.tablespace_name, s2.segment_name,
       i2.table_name, s2.extents, s2.bytes, s2.blocks, i2.status
from dba_segments s2,
       dba_indexes i2
where s2.owner not in ('SYS','SYSTEM')
and s2.segment_type = 'INDEX'
and i2.status != 'VALID'
and s2.segment_name = i2.index_name
and s2.owner = i2.owner
order by 1,5,4

Oracle常用脚本
-- use sys to run this one
select    'ALTER ' || OBJECT_TYPE || ' '||owner||'.' || OBJECT_NAME || ' COMPILE;'
from    all_objects
where    status = 'INVALID'
and object_type in ('PACKAGE','FUNCTION','PROCEDURE', 'TABLE', 'VIEW', 'SEQUENCE', 'TRIGGER');

--   select
  'ANALYZE ' || OBJECT_TYPE || ' ' || OBJECT_NAME || ' COMPUTE STATISTICS;'
from
  user_objects
where
  object_type = 'TABLE';

时间: 2025-01-15 08:49:00

Oracle Compile 编译无效对象(ORA-04063: package body的相关文章

oracle 编译无效对象

1.手动编译 如果无效对象的数量很少,那么你可以逐个编译这些对象. 如 ALTER PACKAGE my_package COMPILE; ALTER PACKAGE my_package COMPILE BODY; ALTER PROCEDURE my_procedure COMPILE; ALTER FUNCTION my_function COMPILE; ALTER TRIGGER my_trigger COMPILE; ALTER VIEW my_view COMPILE; 你也可以用

ebs 编译无效对象——adutlrcmp.sql not giving promt

今天在给R12升级到12.1.3的时候,要安装一个补丁,  打最大的一个patch  p9239090 的时候, 前面还算正常, 到了数据库 编译无效对象的时候,一直不结束,第一次做,有点束手无措,最后从网上找了一些参考,整理了一下: 首先,我的环境是这样提示的: Telling workers to quit... All workers have quit. Dropping FND_INSTALL_PROCESSES table... FND_INSTALL_PROCESSES table

ORACLE中如何批量编译无效对象

SET feedback OFF SET heading OFF SET linesize 1000 SET pagesize 0 SET pause OFF SET trimspool ON SET verify OFF spool tmp.sql; --组装SQL语句 SELECT 'alter '||object_type||' '||owner||'.'||object_name||' compile;' FROM all_objects WHERE status = 'INVALID'

ORACLE编译失效对象

在日常数据库维护过程中,我们会发现数据库中一些对象(包Package.存储过程Procedure.函数Function.视图View.同义词.....)会失效,呈现无效状态(INVALID).有时候需要定期检查数据库中存在哪些失效对象,对于存在异常的对象需要重新编译,有些自动失效的对象,一般会在下次调用的时候,会被重新编译,所以这些不需要人工干预.那么为什么对象突然会失效呢?又如何快速.高效的编译失效对象呢?哪些失效的对象不需要我们去重新编译呢? 数据库对象失效原因 数据库对象失效的原因很多,下

ORACLE编译失效对象小结

在日常数据库维护过程中,我们会发现数据库中一些对象(包Package. 存储过程Procedure.函数Function.视图View.同义词.....)会失效,呈现无效状态(INVALID).有时候需要定期检查数据 库中存在哪些失效对象,对于存在异常的对象需要重新编译,有些自动失效的对象,一般会在下次调用的时候,会被重新编译,所以这些不需要人工干预.那么为什 么对象突然会失效呢?又如何快速.高效的编译失效对象呢?哪些失效的对象不需要我们去重新编译呢? 数据库对象失效原因 数据库对象失效的原因很

重新编译PLSQL中的无效对象或者指定的对象 的方法_oracle

Oracle   Tips,   Tricks   &   Scripts      1.   Topic:   Compiling   Invalid   Objects:      Oracle8i   and   Oracle9i   provides   a   script   called   utlrp.sql   located   in   $ORACLE_HOME/rdbms/admin   which   can   be   used   anytime   to   r

Oracle 错误总结及问题解决 ORA

参考地址 ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常.ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-00020: 超出最大进程数 ()ORA-00021: 会话附属于其它某些进程:无法转换会话ORA-00022: 无效的会话 ID:访问被拒绝ORA-00023: 会话引用进程私用内存:无法分离会话ORA-00024: 单一进程模式下不允许从多个进程注册

oracle DBMS_SQL编译问题

问题描述 oracle DBMS_SQL编译问题 创建的存储过程里面调用DBMS_SQL中的方法,该存储过程能编译通过,但是执行时报SYS.DBMS_SQL有错误,package body中DBMS_SQL有红叉,alter....compile body不报错,但是状态仍然是invalid ,右键DBMS_SQL重新编译 结果 已编译但有错误.

Oracle中如何查看对象持有锁的情况

同事在测试库上对一个表加字段,提示 ORA-00054, 资源忙. 应该是表对象的锁没有释放. 用如下SQL 查看一下系统中相关对象上锁的情况: <pre name="code" class="sql">/* Formatted on 2012/2/13 14:24:32 (QP5 v5.185.11230.41888) */ SELECT S.SID SESSION_ID, S.USERNAME, DECODE (LMODE, 0, ' None ',