MySQL触发器的语法错误

时间:2014-12-30 15:07:46

标签: mysql syntax triggers

我创建了一个简单的触发器,如下所示:

CREATE TRIGGER `trigger_update_rche_prep` BEFORE UPDATE ON `rche_prep` 
FOR EACH ROW 
SET NEW.case_number = 'ABC';

当我想向其添加BEGIN...END语法时,哪个有效,如下所示:

CREATE TRIGGER `trigger_update_rche_prep` BEFORE UPDATE ON `rche_prep` 
FOR EACH ROW 
BEGIN
SET NEW.case_number = 'ABC';
END;

它失败了,我不知道为什么会这样,有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

DELIMITER //
 CREATE TRIGGER `trigger_update_rche_prep` BEFORE UPDATE ON `rche_prep` 
 FOR EACH ROW 
 BEGIN
   SET NEW.case_number = 'ABC';
 END;//
DELIMITER ;