在ORACLE数据库(10.2.0.5.0)上修改一个包的时候,编译有错误,具体错误信息为"ORA-04028: cannot generate diana for object xxx"。
Warning: Package Body created with compilation errors.
SQL> show error;
Errors for PACKAGE BODY XXXXX."XXXXXXXX":
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 ORA-04028: cannot generate diana for object
xxxx.xxxxx
SQL>
第一次遇到这样的错误信息,有点懵,查看错误信息具体解释,解释有lock conflict, 但是所涉及表根本没有任何会话进程锁定。在Meta Link上搜索,才发现是一个Bug
$ oerr ora 4028
04028, 00000, "cannot generate diana for object %s%s%s%s%s"
// *Cause: Cannot generate diana for an object because of lock conflict.
// *Action: Please report this error to your support representative.
当包依赖的视图重建后,如果此时尝试编译包就会遇到这个错误,而我所遇到情况是包所依赖的表重建了。 具体可以参考ORA-4028 ERROR WHILE RECOMPILING PL/SQL PACKAGE (文档 ID 1505092.1),
APPLIES TO:
PL/SQL - Version 10.2.0.5 to 10.2.0.5 [Release 10.2]
Information in this document applies to any platform.
SYMPTOMS
Attempting to compile a package fails after the creation of a dependent view with:
ORA-04028: cannot generate diana for object SCOTT.V_TEST
Testcase Scenario:
SQL> CREATE OR REPLACE VIEW V_TEST
(a, b)
AS
select a,b from test
/
2 3 4 5
View created.
SQL> alter package p_test compile;
alter package p_test compile
*
ERROR at line 1:
ORA-04028: cannot generate diana for object SCOTT.V_TEST
CAUSE
unpublished Bug 9342254 - ORA-4028: CANNOT GENERATE DIANA OBJECT AND ORA-4020 : DEAD LOCK
The defect is fixed in 11.1 or later.
Download and apply the Patch 9342254 for your version and platform.
如上所示,这个是一个bug来的,在ORACLE 11.1以及以后版本已经fix掉了,如果遇到这个问题,要么应用补丁9342254 ,如果不能立马应用补丁,经过测试也有两种方法解决:
1:重启数据库,然后重编译包。这时可以重新编译包,不会遇到这个错误。
2:清空SHARED_POOL,然后重编译包。(ALTER SYSTEM FLUSH SHARED_POOL;)