开发者

Mysql create trigger 1064 error

开发者 https://www.devze.com 2023-01-19 22:03 出处:网络
The sql i wrote **delimiter | CREATE DEFINER=CURRENT_USER TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW

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开发者_如何学C = 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 ?


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


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

精彩评论

暂无评论...
验证码 换一张
取 消