473,666 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table Mutating Error

1 New Member
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_TE ST 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 1544

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

Similar topics

3
6940
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 I've been working with; I am unable to get the INSERT to work? Recommendations; what am I doing wrong? ------------------- CREATE OR REPLACE TRIGGER test AFTER INSERT OR DELETE OR UPDATE ON testdb
2
4714
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
7463
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)?
0
2146
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
7417
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...
5
9348
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
1787
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
1642
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 to the empno being deleted, and set the mgrid=null. The problem coming here is of Mutating table.Is there a simple workaround of this problem? Thx n regards
0
1027
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 look at (or modify) a table that was in the middle of being modified by the statement which fired it. Action: Rewrite the trigger (or function) so it does not read that
0
8356
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
8866
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
8781
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...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
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
7385
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...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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.