SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


"ORA-04091" Mutating Error


"ORA-04091" Mutating Error

Author
Message
Minnu
Minnu
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2497 Visits: 950
ora
hcprasadv
hcprasadv
SSC Eights!
SSC Eights! (937 reputation)SSC Eights! (937 reputation)SSC Eights! (937 reputation)SSC Eights! (937 reputation)SSC Eights! (937 reputation)SSC Eights! (937 reputation)SSC Eights! (937 reputation)SSC Eights! (937 reputation)

Group: General Forum Members
Points: 937 Visits: 342
Check it out at....

http://www.techonthenet.com/oracle/errors/ora04091.php
Minnu
Minnu
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2497 Visits: 950
Already checked the links. but not getting exact solution.

is there any syntax error in trigger any issues.

Please help me...
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (168K reputation)SSC Guru (168K reputation)SSC Guru (168K reputation)SSC Guru (168K reputation)SSC Guru (168K reputation)SSC Guru (168K reputation)SSC Guru (168K reputation)SSC Guru (168K reputation)

Group: General Forum Members
Points: 168365 Visits: 39529
There are a few people here with Oracle experience that may be able to help but you might get better (or faster) answers on a dedicated Oracle forum rather than a MS SQL Server site.

I worked with Oracle for a year but never wrote a trigger so I am not much help here.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Lowell
Lowell
SSC Guru
SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)

Group: General Forum Members
Points: 138871 Visits: 41519
i believe the mutating issue is when you try to update from anything other than the old; or new:
you want to avoid that.

it's not clear what you are trying to update; with no DDL, we can only assume all the columns referenced belong to the MODEL_CODE table the trigger seems to be defined on..

old: would be empty/blank for INSERT commands.
new: would be empty/blank for DELETE commands.

it looks to me like there is no reason whatsoever to try and use the other table USER_ID


CREATE OR REPLACE TRIGGER TRG_IUD
AFTER INSERT OR DELETE OR UPDATE
OF CODE,DESC
ON MODEL_CODE
REFERENCING OLD AS OLD
FOR EACH ROW
BEGIN

UPDATE UID SET DATE_SET = current_timestamp
WHERE UID_ID = :old.code;

END;




Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Minnu
Minnu
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2497 Visits: 950
Hi Team,

given code is not working, here am giving my scenario with details.

Table : Stud
---------------------------------------------------
Stud_Code | Name


View : CST
---------------------------------------------------
Stud_id | LIb_id



Table : LIB
---------------------------------------------------
Lib_id | Current_Date


Stud_Code column in "STUD" and stud_id column in "CST" are similar data.

if there is any insert/update/delete on table "STUD" of columns "Stud_code or Name"

then udpate current_date in LIB table where Lib_id = Lib_id of "CST" view.

am getting mutating error, plz help
Lowell
Lowell
SSC Guru
SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)

Group: General Forum Members
Points: 138871 Visits: 41519
it's been a long time since you followed up on this, and you've changed which tables you are referring to.
did you fix the issue on MODEL_CODE and now have the same mutating issue on another suite of tables?

can you show us the DDL of both the STUD table, and the trigger you created to try and update the LIB table?

there's lots and lots of examples you could modify if you are stuck on syntax, so you've got to provide a lot more detail if you want help from a forum.

Search q=oracle+trigger+update+another+table

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Minnu
Minnu
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2497 Visits: 950
Hi,

Below is the query am using..

create or replace trigger tr_stud
after insert or update or delete
of stud_code , name
on stud
referencing old as old new as new
for each row

begin

update lib set current_date =current_date
where
(select c.lib_id from cst c, stud t
where t.stud_code=c.stud_id);
end;
Lowell
Lowell
SSC Guru
SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)SSC Guru (138K reputation)

Group: General Forum Members
Points: 138871 Visits: 41519
Minnu (4/16/2013)
Hi,

Below is the query am using..

create or replace trigger tr_stud
after insert or update or delete
of stud_code , name
on stud
referencing old as old new as new
for each row

begin

update lib set current_date =current_date
where
(select c.lib_id from cst c, stud t
where t.stud_code=c.stud_id);
end;

well you didn't provide anything i can paste into Oracle SQLDeveloperr/TOAD, so all i can do is best-guess at syntax.

your not referencing new; or old: anywhere, and you should have separate logic for when you insert vs when you delete...for example, why would you update the other table to some value if a row was deleted? you know your logic better than me, obviously.

for example, if this trigger is doing insert/update/delete, i'd expect a block of code to determine each action?

BEGIN
IF inserting
THEN
trigger_api.tab1_row_change(p_id => :new.projectid, p_action => 'INSERT');
ELSIF updating
THEN
trigger_api.tab1_row_change(p_id => :new.projectid, p_action => 'UPDATE');
ELSIF deleting
THEN
trigger_api.tab1_row_change(p_id => :old.projectid, p_action => 'DELETE');
END IF;
END;



until you are able to provide the complete table ddls (for all teh tables involved), the compete trigger, and a sample insert/update/delete and finally your expected results for each action, you are still going to have to google for the syntax and get it to work yourself.
Best of luck to you!

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Minnu
Minnu
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2497 Visits: 950
Thanks.

what ever i have, i given to you and asking for suggetion / help to come out from the error.

if u want detailed ddl's and trigger.

i'll complete the trigger after successfully execution without errors,

i'll send u the code.

Any how thanks.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search