473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Table Mutating Error

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, join_date, empsal, emp_desig) values (11, 'Alan',
'01-apr-04', 12000, 'PROGRAMMER');
insert into emp_test (empno, empname, join_date, empsal, emp_desig) values (11, 'Alan', '01-a
*
ERROR at line 1:
ORA-04091: table PRACTICE.EMP_TEST is mutating, trigger/function may not see it
ORA-06512: at "PRACTICE.TEST_TRIG", line 9
ORA-06512: at "PRACTICE.TEST_TRIG", line 13
ORA-04088: error during execution of trigger 'PRACTICE.TEST_TRIG'

************************************************** *****************************
Body of the Trigger is as follows:
################################################## ######

SET SERVEROUTPUT ON
SET VERIFY OFF
create or replace trigger test_trig
after insert on emp_test for each row
declare
getempno number(5);
getempname varchar2(50);
getjoindate date;
getsal number(10,2);
getdesig varchar2(50);

cursor empcur is
select empno, empname, join_date, empsal, emp_desig from

emp_test where empno=(select max(empno) from emp_test);
cur_exp exception;
begin
open empcur;
loop
fetch empcur into getempno, getempname, getjoindate, getsal,

getdesig;
exit when empcur%NOTFOUND;
insert into newemp_test values(getempno, getempname,

getjoindate, getsal, getdesig);
end loop;
if empcur%ROWCOUNT = 0 then
close empcur;
raise cur_exp;
end if;
exception
when cur_exp then
DBMS_OUTPUT.PUT_LINE('No Record found. ! ');
end;
/
SET VERIFY ON
SET SERVEROUTPUT OFF
################################################## ###########
Jan 11 '07 #1
0 1534

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

Similar topics

3
by: Tom Urbanowicz | last post by:
I have a trigger. Each time the triggering event fires, I want to insert some information into another 'audit-like' table (not at all related to the trigger). Some psuedo-code is below as to what...
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...
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: 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...
2
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...
5
kiss07
by: kiss07 | last post by:
Dear daba, Also, WHAT IS Mutating table and what is mutating trigger?How can i eliminate mutating trigger error? Pls .I preparing interview. Pls some coding.
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: mask | last post by:
I am writing a trigger for delete event of employee table (PK - empno, Mrgid - Self referencing key ) in oracle .In the trigger , i wish to update the rows of the same table which have mgr id equal...
0
by: Daniel Roy | last post by:
From Oracle: ORA-04091 table string.string is mutating, trigger/function may not see it Cause: A trigger (or a user defined PL/SQL function that is referenced in this statement) attempted to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.