Unix Technical Forum

Mutating table with old and new ... only

This is a discussion on Mutating table with old and new ... only within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hello, I have been told that something like: create trigger triggername before update of ROW on TABLE for each ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-29-2008, 09:59 AM
Dirk Wendt
 
Posts: n/a
Default Mutating table with old and new ... only

Hello,

I have been told that something like:

create trigger triggername
before update of ROW on TABLE
for each row
when (old.ROW = a and new.ROW = b)
begin
:new.ROW := ld.ROW;
.... message "a could not be updated with b"
end;
/

would cause the mutating table error. Certainly I have tried it out and did
not receive this error. From my knowledge
new and old are just "copies" and since I am not accessing the table/row
which is going to be updated/or not an
mutating error could not happen in this context, right? In general I wonder
if the trigger above could be used or if it
is better to have such logic somewhere else?

Thanks much in advance for you help.


Best regards,
Dirk.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-29-2008, 09:59 AM
DA Morgan
 
Posts: n/a
Default Re: Mutating table with old and new ... only

Dirk Wendt wrote:
> Hello,
>
> I have been told that something like:
>
> create trigger triggername
> before update of ROW on TABLE
> for each row
> when (old.ROW = a and new.ROW = b)
> begin
> :new.ROW := ld.ROW;
> .... message "a could not be updated with b"
> end;
> /
>
> would cause the mutating table error. Certainly I have tried it out and did
> not receive this error. From my knowledge
> new and old are just "copies" and since I am not accessing the table/row
> which is going to be updated/or not an
> mutating error could not happen in this context, right? In general I wonder
> if the trigger above could be used or if it
> is better to have such logic somewhere else?
>
> Thanks much in advance for you help.
>
>
> Best regards,
> Dirk.


What you describe will not cause a mutating table error.

Go to Morgan's Library at www.psoug.org and click on
Table Triggers.

Run the demo that creates the error to learn what creates
it and how to avoid it.

Essentially what must happen to create the error is that
the trigger must query the table on which DML is being
performed.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-29-2008, 09:59 AM
joel garry
 
Posts: n/a
Default Re: Mutating table with old and new ... only

On Aug 27, 12:07*pm, "Dirk Wendt" <i...@dpcw.de> wrote:
> Hello,
>
> I have been told that something like:
>
> create trigger triggername
> before update of ROW on TABLE
> for each row
> when (old.ROW = a and new.ROW = b)
> begin
> * :new.ROW := ld.ROW;
> * .... message "a could not be updated with b"
> end;
> /
>
> would cause the mutating table error. Certainly I have tried it out and did
> not receive this error. From my knowledge
> new and old are just "copies" and since I am not accessing the table/row
> which is going to be updated/or not an
> mutating error could not happen in this context, right? In general I wonder
> if the trigger above could be used or if it
> is better to have such logic somewhere else?
>
> Thanks much in advance for you help.
>
> Best regards,
> Dirk.


I think you would get it once you add a relational integrity
constraint or if someone else is updating the table. See
http://asktom.oracle.com/tkyte/Mutate/index.html (which refers to the
docs http://download-west.oracle.com/docs...g13trg.htm#786
) and search on the term mutating at asktom.oracle.com for the many
variants of this.

You have to remember when you try things out to try the things that
will cause the problem. This can be more difficult than some people
expect, given a complicated system.

jg
--
@home.com is bogus.
Wormmmmmsss innnnn Spaaaaaaacccce. http://news.bbc.co.uk/1/hi/technology/7583805.stm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads for: Mutating table with old and new ... only

Thread Thread Starter Forum Replies Last Post
Need workaround for Oracle Mutating table swapnil.kale@gmail.com Oracle Miscellaneous 18 04-08-2008 12:23 PM
Mutating Table - Not working with INSERT pankaj_wolfhunter@yahoo.co.in Oracle Miscellaneous 7 04-08-2008 12:17 PM
Trigger / mutating table Juha Laiho Oracle Database 2 02-26-2008 06:32 AM
ORA-04091: table ... is mutating, trigger/function may not see it cookie monster Oracle Database 3 02-24-2008 04:12 PM
Help with Mutating Table - Are there other solutions? contrapositive Oracle Database 8 02-23-2008 06:18 AM


All times are GMT. The time now is 08:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com