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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 := .... 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. |
| |||
| 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 := > .... 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 |
| ||||
| 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 := > * .... 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 |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| 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 |