Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

"ORA-04091" Mutating Error Expand / Collapse
Author
Message
Posted Friday, March 29, 2013 8:04 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, September 26, 2014 7:36 AM
Points: 229, Visits: 730
ora
Post #1436944
Posted Friday, March 29, 2013 8:14 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Monday, October 6, 2014 6:26 AM
Points: 729, Visits: 341
Check it out at....

http://www.techonthenet.com/oracle/errors/ora04091.php
Post #1436953
Posted Friday, March 29, 2013 8:18 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, September 26, 2014 7:36 AM
Points: 229, Visits: 730
Already checked the links. but not getting exact solution.

is there any syntax error in trigger any issues.

Please help me...
Post #1436956
Posted Friday, March 29, 2013 9:06 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 6:26 PM
Points: 20,732, Visits: 32,496
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.



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)
Post #1436968
Posted Friday, March 29, 2013 9:13 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 6:44 AM
Points: 12,905, Visits: 32,158
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1436970
Posted Tuesday, April 16, 2013 3:17 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, September 26, 2014 7:36 AM
Points: 229, Visits: 730
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
Post #1442655
Posted Tuesday, April 16, 2013 5:17 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 6:44 AM
Points: 12,905, Visits: 32,158
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1442691
Posted Tuesday, April 16, 2013 6:55 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, September 26, 2014 7:36 AM
Points: 229, Visits: 730
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;
Post #1442719
Posted Tuesday, April 16, 2013 7:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 6:44 AM
Points: 12,905, Visits: 32,158
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1442732
Posted Tuesday, April 16, 2013 7:40 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, September 26, 2014 7:36 AM
Points: 229, Visits: 730
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.

Post #1442740
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse