What's wrong with my MYSQL trigger syntax?
CREATE TRIGGER event_house_dealed AFTER UPDATE ON house FOR EACH ROW
BEGIN
DECLARE finished IN开发者_开发问答T;
IF NEW.isdeal = 1 THEN
SET finished = 1;
END IF;
END;
The MySQL server keep saying
SQL Error (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 'IF NEW.isdeal = 1 THEN SET finished = 1' at line 1
Thanks.
You need to change delimiter before defining trigger
DELIMITER ||
CREATE TRIGGER event_house_dealed AFTER UPDATE ON house FOR EACH ROW
BEGIN
DECLARE finished INT;
IF NEW.isdeal = 1 THEN
SET finished = 1;
END IF;
END||
Then of course change the delimiter back to ;
DELIMITER ;
Same goes for declaring functions and stored procedures
精彩评论