472,972 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,972 software developers and data experts.

ERROR :Trigger is mutating, trigger/function may not see it

Hello,

Can any one help me in creating a trigger to update system date into a table while inserting a record into that table. I tried it like this, it is showing error !!!


The following error has occurred:

ORA-04091: table ACG.CENTREMST is mutating, trigger/function may not see it
ORA-06512: at "ACG.CENTREMST_INSERT", line 5
ORA-04088: error during execution of trigger 'ACG.CENTREMST_INSERT'

The TRIGGER I created like this....

CREATE OR REPLACE TRIGGER CentreMst_insert
AFTER INSERT on Centremst FOR EACH ROW
DECLARE
vStmt VARCHAR2(200);
CKEY VARCHAR2(15);
BEGIN
SELECT :new.cocode||TO_CHAR(:new.CentreType)||:new.Centre code INTO CKEY FROM CENTREMST;
vStmt := 'Update CentreMst Set CreatedDt = SysDate Where Cocode||CENTRETYPE||CentreCode='||CKEY;
EXECUTE IMMEDIATE vStmt ;
END;

Regards
Reshmi
Oct 16 '06 #1
2 12175
Usted no puede ejecutar transacciones sobre la misma tabla en un trigger.

Si usted necesita modificar la fecha del registro que se esta insertando (Col. CreatedDt) el trigger deberia ser:

CREATE OR REPLACE TRIGGER CentreMst_insert
BEFORE INSERT on Centremst
REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW FOR EACH ROW
BEGIN
:NEW.CreatedDt := Sysdate;
END;


Hello,

Can any one help me in creating a trigger to update system date into a table while inserting a record into that table. I tried it like this, it is showing error !!!


The following error has occurred:

ORA-04091: table ACG.CENTREMST is mutating, trigger/function may not see it
ORA-06512: at "ACG.CENTREMST_INSERT", line 5
ORA-04088: error during execution of trigger 'ACG.CENTREMST_INSERT'

The TRIGGER I created like this....

CREATE OR REPLACE TRIGGER CentreMst_insert
AFTER INSERT on Centremst FOR EACH ROW
DECLARE
vStmt VARCHAR2(200);
CKEY VARCHAR2(15);
BEGIN
SELECT :new.cocode||TO_CHAR(:new.CentreType)||:new.Centre code INTO CKEY FROM CENTREMST;
vStmt := 'Update CentreMst Set CreatedDt = SysDate Where Cocode||CENTRETYPE||CentreCode='||CKEY;
EXECUTE IMMEDIATE vStmt ;
END;

Regards
Reshmi
Oct 16 '06 #2
Hello

Thanks, it worked.

But I didn't get thru your language :)

Once again Thanks

Regards
Reshmi
Oct 17 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: robert | last post by:
i've found the solution threads on changing a column on insert. works fine. question: - will one package serve for all such triggers, or does there need to be a package defined to support...
2
by: Galina | last post by:
Hello I work with Oracle 9 database. I want to create a trigger using 2 tables: KEY_SKILLS_STUDENT and KEY_SKILLS. There are fields in KEY_SKILLS_STUDENT: KEY_SKILLS_ID, PORTFOLIO_RESULT and...
4
by: M | last post by:
Hello, I have a very simple table, and want to create a trigger that updates the date column entry (with the current date), whenever a row gets modified. Is there a simple way of fixing this,...
0
by: gustavo_randich | last post by:
Hello, I'm looking for a DB2 workaround on a topic already solved in Oracle: the problem of mutating tables (which states that a trigger action cannot read the triggering table's data). Yes, I...
0
by: AYAN MUKHERJEE | last post by:
I have 2 tables. 1) emp_test, 2) newemp_test. I had created a trigger to insert automatic data in the table no. 2 , as soon as a row of information is inserted in table no. 1. The Trigger had been...
3
by: extremexpert | last post by:
Hai all, I have two tables like hdr and det. I would like to create the trigger for the situation ' 1.Delete Det table records, if any record is deleting in hdr table 2. Delte hdr table...
3
by: dmanojbaba | last post by:
i have a table with values like 1,2,3.... (primary key) if i delete a row eg.4, i need my trigger to update the values 5 to 4,6 to 5, 7 to 6,.. like that, after deleting 4. pls help me... my...
1
by: gangulajagan | last post by:
Could any one please explain me what is a Mutating Table Or Mutaing Trigger and how to overcome it? Are both Mutating trigger and Mutating Table one and same? Please Explain me with an example...
16
by: vamsioracle | last post by:
Can Someone help me how to avoid mutating error while using triggers. I work on oracle apps. I created a vacation rule such that responsibility is delegated to other person. These details are...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.