现在的位置: 首页 > 综合 > 正文

Can’t update table ‘tbl’ in stored function/trigger because it is already used by statement which invoked this stored function/t

2014年02月15日 ⁄ 综合 ⁄ 共 495字 ⁄ 字号 评论关闭

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!

抱歉!评论已关闭.