473,794 Members | 2,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mutating trigger Error

15 New Member
Hi every one,
I am trying to update time_added column when ever there is an update on the table.
ALTER TABLE emp
ADD (time_added timestamp);

UPDATE emp
SET time_added = sysdate;

When ever i issue any update stmt like these,automatic ally time_added column should also be update.
I tried creating a trigger,but I could acheive the expected result.
UPDATE emp
SET deptno = 11
WHERE deptno = 10;

Please can you give me the trigger code to acheive my task, or do we have any other alternatives.

Regards
Raghu
Aug 2 '07 #1
9 2871
debasisdas
8,127 Recognized Expert Expert
please post your code with the table structure .
Aug 3 '07 #2
tedlaraghu
15 New Member
SQL> desc emp
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
DEPTNAME VARCHAR2(50)
TIME_ADDED TIMESTAMP(6)

It is a default oracle table, so i am not providing data
Aug 3 '07 #3
debasisdas
8,127 Recognized Expert Expert
Along with the table structure , I have asked you to post your code for my recerence and check the same .

Where is the code ?
Aug 4 '07 #4
tedlaraghu
15 New Member
create or replace trigger upd_time
after update on emp
for each row
begin
update emp
set time_added = sysdate;
end;

update emp
set sal = 10000
where deptno =11;

ERROR at line 1:
ORA-04091: table SCOTT.EMP is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.UPD_TIME ", line 2
ORA-04088: error during execution of trigger 'SCOTT.UPD_TIME '
Aug 4 '07 #5
dmanojbaba
5 New Member
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 table ABC with QNO as primary key.

my trigger
create or replace trigger t1 after delete on abc
referencing old as orow
for each row
declare
begin
update abc set qno=qno-1 where qno>:orow.qno;
end;
Trigger Created

but when i exec the command
delete abc where qno=3;

i get the error msg
delete qb1 where qno=2
*
ERROR at line 1:
ORA-04091: table RECCSE.ABC is mutating, trigger/function may not see it
ORA-06512: at "RECCSE.T1" , line 4
ORA-04088: error during execution of trigger 'RECCSE.T1'


pls help me.....:(
--------------------------------------------------------------------------------
Aug 7 '07 #6
debasisdas
8,127 Recognized Expert Expert
create or replace trigger upd_time
after update on emp
for each row
begin
update emp
set time_added = sysdate;
end;

update emp
set sal = 10000
where deptno =11;

ERROR at line 1:
ORA-04091: table SCOTT.EMP is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.UPD_TIME ", line 2
ORA-04088: error during execution of trigger 'SCOTT.UPD_TIME '

in this case the trigger is mutating because it is trying to update the base table from which it is reading data.
Aug 7 '07 #7
debasisdas
8,127 Recognized Expert Expert
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 table ABC with QNO as primary key.

my trigger
create or replace trigger t1 after delete on abc
referencing old as orow
for each row
declare
begin
update abc set qno=qno-1 where qno>:orow.qno;
end;
Trigger Created

but when i exec the command
delete abc where qno=3;

i get the error msg
delete qb1 where qno=2
*
ERROR at line 1:
ORA-04091: table RECCSE.ABC is mutating, trigger/function may not see it
ORA-06512: at "RECCSE.T1" , line 4
ORA-04088: error during execution of trigger 'RECCSE.T1'

--------------------------------------------------------------------------------

same problem in this case also.
Aug 7 '07 #8
tedlaraghu
15 New Member
Can you give us work arounds
Aug 8 '07 #9
debasisdas
8,127 Recognized Expert Expert
Please find the details regarding this problem and realted solutions here and here.
Aug 8 '07 #10

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

Similar topics

2
4720
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 each table? my o'reilly book doesn't say, nor do the threads i found.
4
7474
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, or would I have to create 3 extra triggers, a package, etc., as described in most posts about mutating table errors? Could you please explain to me WHY this error happens here (I have not been able to find a clear explanation of what causes them)?
4
7060
by: M Mueller | last post by:
Hello - I'm using Oracle 8i and am running into the infamous mutating table error on an AFTER INSERT OR UPDATE FOR EACH ROW trigger. I have seen examples for getting around mutating table errors if you either need access to the :old or the :new values within a trigger. But what if you need access to both? Or is this even possible (I'm fairly new to triggers). I have to execute a select count(*) from trigger_table where
0
2160
by: hankr | last post by:
I have only a developer's level knowledge of Oracle, though I have access to DBA tools. Searches through the docs have not been fruitful, so I thought I'd try here. I am getting an error on a simple 1-row I-SQL delete statement that a different table may be "mutating" and the transaction is then rolled-back. I understand what this means, and have fixed "mutating" errors before. But I cannot for the life of me trace-thru in the...
2
12219
by: Reshmi Jacob | last post by:
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'
0
1554
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 successfully done, but as I try to insert a row in the table after running the Trigger this error is getting generated. ************************************************************************************** SQL> insert into emp_test (empno, empname,...
2
7423
by: hemalatha natarajan | last post by:
hi, I just created a trigger to avoid inserting the same data into table . If same data is inserted then error msg should be thrown. I created a trigger but when it is executed during insertion it is giving mutating error. can anyone please help me??? please mail me to my personal id .thanks in advance CREATE OR REPLACE TRIGGER tr_project_dates_duplicate BEFORE INSERT ON PROJECT_DATES FOR EACH ROW DECLARE lv_type CHAR; lv_count...
3
1803
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 table ABC with QNO as primary key. my trigger create or replace trigger t1 after delete on abc referencing old as orow
1
3421
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 if possible. Thanks in advance.
16
7045
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 captured in wf_routing_rules. I created a procedure that takes the values from wf_routing_rules and sends mail using utl_smtp. I created a trigger such that for every row insert in wf_routing_rules, this procedure is called. I know that doing a...
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.