用mysql写触发器,老是没办法定义,报错
后来不断的弱化触发器的功能,直到只给其中一个字段加一些值了,还是不行
杯具啊
后来,触发器能定义好了,执行的时候又遇到问题了,也就是说触发器被触发,但是里面的操作没有执行。
去啊,尼玛坑爹吶
报错是这个:
Can’t update table ‘visited_cate’ in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
查完中文查英文,你妈呀,不支持操作啊
看csdn上的一个例子吧
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
官方论坛这么说啊:
when you insert a record mysql is doing some lock stuff. you can’t insert/update/delete rows of the same table where you insert.. because then the trigger would called again and again.. ending up in a recursion
创建触发器时这么说啊:
Updating of NEW row is not allowed in after trigger
那尼玛的mysql还支持什么触发器啊,不要不就完了吗,sqlserver虽然烂,但也不至于这样啊
杯具啊
文章来源:毛蛋网(maoegg.com)




评论
发表评论 反向链接