Mysql Trigger无法正常工作,不知道bug在哪里

时间:2013-04-30 11:39:31

标签: mysql database triggers

CREATE TRIGGER pointclosedtrigger AFTER UPDATE ON points
 FOR EACH ROW BEGIN
 IF NEW.is_open='3'
 THEN
  INSERT into point_history (idpoints,idmembers,action_time,action_type)
  VALUES (OLD.idpoints,NEW.idmembers,NOW(),'2');
 END IF;
END

1 个答案:

答案 0 :(得分:0)

您忘了定义分隔符

delimiter |
CREATE TRIGGER `pointclosedtrigger` AFTER UPDATE ON `points`
 FOR EACH ROW BEGIN
 IF NEW.is_open='3'
 THEN
  INSERT into point_history (`idpoints`,`idmembers`,`action_time`,`action_type`)
  VALUES (OLD.`idpoints`,NEW.`idmembers`,NOW(),'2');
 END IF;
END
|
delimiter ;

如果您没有定义另一个分隔符而不是;,那么您的陈述将在第一个;结束,并且它将不完整。