mysql 触发器的问题 Can't update table 'tbl' in stored function/trigger because it is already used by state

原文:http://blog.csdn.net/java2000_net/article/details/3857579

如果你在触发器里面对刚刚插入的数据进行了 insert/update, 则出现这个问题。因为会造成循环的调用.

 

create trigger test
before update on test
for each row
  update test set NEW.updateTime = NOW() where id=NEW.ID;
END


应该使用set操作,而不是在触发器里使用 update,比如

create trigger test
before update on test
for each row
set NEW.updateTime = NOW();
END

你可能感兴趣的:(mysql,mysql,触发器)