2010-10-10 164 views
0

我寫mysql的創建觸發器1064錯誤

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

錯誤如何解決這種情況的SQL?我做錯了哪裏?

回答

3

看起來你只需要用分號來終止你的UPDATE語句。

+0

我忽略總是SQL分號..問題解決了感謝。 – 2010-10-10 15:21:03

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 ;