当前位置: 代码迷 >> Ruby/Rails >> ORA-00604: error occurred at recursive SQL level 一
  详细解决方案

ORA-00604: error occurred at recursive SQL level 一

热度:263   发布时间:2016-04-29 02:15:59.0
ORA-00604: error occurred at recursive SQL level 1

在测试环境中使用某个账号ESCMOWNER对数据库进行ALTER操作时,老是报如下错误:

 

ORA-00604: error occurred at recursive SQL level 1

ORA-20016: (ALTER) Action denied as it is a protected object!

ORA-06512: at line 7

 

不清楚发生了什么情况,于是想跟踪当前会话,查看具体原因,查看当前会话的SID为967

SELECT USERENV('SID') FROM DUAL;

 

以system登录,查看会话ID=967的SID,SERIAL#

SELECT SID, SERIAL# FROM V$SESSION WHERE SID=967;

 

clip_image001

 

跟踪会话ID、SERIAL#为967,2276的会话,如下所示:

SQL> exec dbms_system.set_sql_trace_in_session(967,2276,true);
 
PL/SQL procedure successfully completed.
 

 

在会话967中启用跟踪标识,如下所示

ALTER SESSION SET TRACEFILE_IDENTIFIER='kerry_test'

 

ORACLE 10g 的跟踪文件位于$ORACLE_BASE/admin/SID/udump 下,查看跟踪文件,

[[email protected] udump]$ ls *kerry*

epps_ora_1960_kerry_test.trc

[[email protected] udump]$ more epps_ora_1960_kerry_test.trc

具体的内容如下所示

clip_image002

 

查看SELECT * FROM DBA_OBJECTS WHERE OBJECT_NAME='PROTECT_ESCMOWNER_BTR' 发现PROTECT_ESCMOWNER_BTR为触发器,具体脚本如下所示

CREATE OR REPLACE TRIGGER PROTECT_ESCMOWNER_BTR
BEFORE DDL
ON ESCMOWNER.SCHEMA
BEGIN
   if sys.sysevent = 'ALTER' and sys.dictionary_obj_type in ('TRIGGER','VIEW','PACKAGE','PACKAGE BODY','PROCEDURE','FUNCTION','SYNONYM') then
      NULL;
   elsif sys.sysevent = 'ANALYZE' then
        NULL;
      else
        RAISE_APPLICATION_ERROR(-20016,'('||sys.sysevent||') Action denied as it is a protected object!');
   end if;
END PROTECT_ESCMOWNER_BTR;

 


结论:

    这个数据库触发器应该是前任DBA设置的,而我一直使用system更新脚本,所以一直没有触发该触发器。禁用该触发器后问题解决。

  相关解决方案