本文介绍了触发错误ORA-04092 ORA-04088的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个触发器,如下所示:

I created a trigger as below:

CREATE OR REPLACE TRIGGER trigger_test
AFTER INSERT ON trigger_1
FOR EACH ROW
DECLARE
t_identifier VARCHAR2(10);
t_name VARCHAR2(20);
BEGIN
t_identifier := (:NEW.IDENTIFIER);
t_name := (:NEW.NAME);
INSERT INTO trigger_2(IDENTIFIER,NAME)VALUES(t_identifier,t_name);
COMMIT;
END;

我正在尝试在Trigger_1中插入一行

I am trying to insert a row in trigger_1

INSERT INTO trigger_1(IDENTIFIER,NAME)
VALUES('1234567','Vijay');

它给了我错误:

ORA-04092: cannot COMMIT in a trigger
ORA-06512: at "LVSDBO46.TRIGGER_TEST", line 8
ORA-04088: error during execution of trigger 'LVSDBO46.TRIGGER_TEST'

有人可以帮忙吗?

推荐答案

只需删除

COMMIT;

从触发代码开始.在正在进行的事务中触发执行,因此您无法进行单独的提交.提交事务后,您在trigger_2中的插入也将提交.

from the trigger code. Trigger execute in an ongoing transaction, so you cannot do a separate commit. When the transaction is commited, your insert in trigger_2 will also be commited.

这篇关于触发错误ORA-04092 ORA-04088的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 05:30