ORA-00604: error occurred at recursive SQL level 1
2015-02-26 22:44 潇湘隐者 阅读(27134) 评论(0) 编辑 收藏 举报在测试环境中使用某个账号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;
跟踪会话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 下,查看跟踪文件,
[oracle@get-linux01 udump]$ ls *kerry*
epps_ora_1960_kerry_test.trc
[oracle@get-linux01 udump]$ more epps_ora_1960_kerry_test.trc
具体的内容如下所示
查看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更新脚本,所以一直没有触发该触发器。禁用该触发器后问题解决。