Mysql create trigger 1064 error

喜你入骨 提交于 2019-12-25 04:43:51

问题


The sql i wrote

**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 ;**

The error given

[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**

How to solve this ? where is the mistake i do ?


回答1:


It looks like you simply need to terminate your UPDATE statement with a semicolon.




回答2:


Try this code

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 ;


来源:https://stackoverflow.com/questions/3900570/mysql-create-trigger-1064-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!