Mysql创建触发器1064错误

时间:2010-10-10 13:56:20

标签: mysql triggers mysql-error-1064

我写的sql

**delimiter |
CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id
END 
|
delimiter ;**

给出的错误

[SQL] 
**CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id
END 
;
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 6**

如何解决这个问题?我做错了哪里?

2 个答案:

答案 0 :(得分:3)

看起来您只需要用分号终止UPDATE语句。

答案 1 :(得分:0)

试试此代码

delimiter |
CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id;
END;|
delimiter ;