An ORA-04091 exception occurred when the ORACLE trigger assigned a value to the table's own field.

Source: Internet
Author: User

The business description is as follows:

When inserting a table, you need to update the value of another field based on the value of one field. Of course, it can also be implemented through a program, but this field is only used for data exchange. It has nothing to do with the main business of the system and does not want to modify the program. Therefore, it can be implemented using a trigger.


Table Structure Definition and trigger definition are as follows:

create table debug_demo1(id varchar(32),name varchar(100),note varchar(200),primary key(id));create or replace trigger tri_debug_demo1before insert on debug_demo1for each rowbeginupdate debug_demo1 set note = 'test' where id = :new.id;end tri_debug_demo1;


As a result, an oracle ORA-04091 exception occurred while performing the insert operation.

ORA-04091: The table debug_demo1 has changed trigger/function cannot read it
ORA-06512: In tri_debug_demo1 line...
ORA-04088: tri_debug_demo1 error during execution


For this exception, this post is described in detail at http://www.iteye.com/topic/1124681.


After reading this post at http://www.itpub.net/thread-1615812-1-1.html, I found a new website, which directly assigned values to the field.


The modified trigger is as follows:

create or replace trigger tri_debug_demo1before insert on debug_demo1for each rowbegin:new.note := 'test';end tri_debug_demo1;


After testing, the insert operation can be performed normally and the expected results can also be met.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.