MySQL Forums
Forum List  »  Triggers

Re: Can't update table 'tbl' in stored function/trigger because it is already used by statement which invoked this stored function/trigger
Posted by: Jody Robbins
Date: March 18, 2008 10:13AM

I know this is an old post but I stumbled on the answer and thought I would share. During the insert/update you have access to the NEW object which contains all of the fields in the table involved. If you do a before insert/update and edit the field(s) that you want to change in the new object it will become a part of the calling statement and not be executed as a separately (eliminating the recursion)
ex.
create trigger test
before update on test
for each row
set NEW.updateTime = NOW();

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Can't update table 'tbl' in stored function/trigger because it is already used by statement which invoked this stored function/trigger
25555
March 18, 2008 10:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.