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: Peter Betzler
Date: November 21, 2006 10:43PM

What's that stuff about recursion?

CREATE TABLE a (
id int(11) NOT NULL auto_increment primary key,
ref int,
updttime datetime
);

DELIMITER |

CREATE TRIGGER buildref AFTER INSERT ON a
FOR EACH ROW BEGIN
UPDATE a SET a.ref = NEW.id, a.updttime = NOW() WHERE a.id = NEW.id;
END;
|

DELIMITER ;

insert into a values(0,0,0) should work!

What's so recursive about that? The record is created and an update should occur.
There is no way to invoce AFTER INSERT again, because it's not INSERT but UPDATE.
What's wrong with that? It runs in Oracle and Informix. Can't find any reason why this should not work!

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
18182
November 21, 2006 10:43PM


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.