dbTalk Databases Forums  

Mutating table with old and new ... only

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Mutating table with old and new ... only in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dirk Wendt
 
Posts: n/a

Default Mutating table with old and new ... only - 08-27-2008 , 02:07 PM






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.



Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:32 PM






Dirk Wendt wrote:
Quote:
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


Reply With Quote
  #3  
Old   
DA Morgan
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:32 PM



Dirk Wendt wrote:
Quote:
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


Reply With Quote
  #4  
Old   
DA Morgan
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:32 PM



Dirk Wendt wrote:
Quote:
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


Reply With Quote
  #5  
Old   
DA Morgan
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:32 PM



Dirk Wendt wrote:
Quote:
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


Reply With Quote
  #6  
Old   
joel garry
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:44 PM



On Aug 27, 12:07*pm, "Dirk Wendt" <i... (AT) dpcw (DOT) de> wrote:
Quote:
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


Reply With Quote
  #7  
Old   
joel garry
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:44 PM



On Aug 27, 12:07*pm, "Dirk Wendt" <i... (AT) dpcw (DOT) de> wrote:
Quote:
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


Reply With Quote
  #8  
Old   
joel garry
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:44 PM



On Aug 27, 12:07*pm, "Dirk Wendt" <i... (AT) dpcw (DOT) de> wrote:
Quote:
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


Reply With Quote
  #9  
Old   
joel garry
 
Posts: n/a

Default Re: Mutating table with old and new ... only - 08-27-2008 , 06:44 PM



On Aug 27, 12:07*pm, "Dirk Wendt" <i... (AT) dpcw (DOT) de> wrote:
Quote:
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


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.