在ORACLE資料庫(10.2.0.5.0)上修改一個包的時候,編譯有錯誤,具體錯誤信息為"ORA-04028: cannot generate diana for object xxx"。 Warning: Package Body created with compilation errors.... ...
在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;)