今天,通过MS SQL Server远程修改Oracle一张表的数据时引发了ORA-04091的错误。错误信息如下:
链接服务器"ORCL61"的 OLE DB 访问接口 "MSDAORA" 返回了消息 "
ORA-04091: table SZKINGGO.TAWB_AWB is mutating, trigger/function may not see it
ORA-06512: at "SZKINGGO.PROC_UAGENTEXPENSE", line 26
ORA-06512: at "SZKINGGO.TRIG_TAWB_AWBCHARGE", line 166
ORA-04088: error during execution of trigger 'SZKINGGO.TRIG_TAWB_AWBCHARGE'
ORA-06512: at "SZKINGGO.TRIG_TAWB_AWB", line 91
ORA-04088: error during execution of trigger 'SZKINGGO.TRIG_TAWB_AWB'
"。
消息 7343,级别 16,状态 4,过程 PROC_AWB,第 251 行
链接服务器 "ORCL61" 的 OLE DB 访问接口 "MSDAORA" 无法 UPDATE 表 "[MSDAORA]"。
[@more@]首先查询下ORA-04091错误的相关信息:
[oracle@lonion ~]$ oerr ora 04091
04091, 00000, "table %s.%s is mutating, trigger/function may not see it"
*Cause: A trigger (or a user defined plsql function that is referenced in this statement) attempted to
look at (or modify) a table that was in the middle of being modified by the statement which
fired it.
*Action: Rewrite the trigger (or function) so it does not read that table.
根据错误的描述,可以得知触发当前表的触发过程中又对该表进行了SELECT或DML的操作。为了避免这个错误,在写触发器的时候,尽可能的避免对当前表的引用。
我当前问题出现ORA-04091的原因是:当前触发器调用了存储过程PROC_UAGENTEXPENSE,而PROC_UAGENTEXPENSE中又对引发触发的表进行了SELECT操作。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24389441/viewspace-1057431/ ,如需转载,请注明出处,否则将追究法律责任。