开发者

MYSQL Trigger definition -- 1064 error

I keep getting ERROR 1064 with the 开发者_开发知识库below trigger statement "..for the right syntax to use near '' at line 5" I have struggled with it for a couple of hours but just cannot figure out what is wrong!

DELIMITER $$
CREATE TRIGGER status_upd AFTER UPDATE ON order_products
FOR EACH ROW
BEGIN
    IF OLD.status_id != NEW.status_id THEN INSERT INTO op_status values(op_id,     NEW.status_id, curdate());
END$$
DELIMITER ;                                    

Any suggestion, what I could be doing wrong. Thank You


I think it should be like this:

DELIMITER $$ 
CREATE TRIGGER status_upd AFTER UPDATE ON order_products 
FOR EACH ROW 
BEGIN
IF (OLD.status_id != NEW.status_id) THEN 
INSERT INTO op_status values(op_id,NEW.status_id, curdate());
END IF;
END$$
DELIMITER;

You were missing the END IF;.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜