开发者

MySQL syntax error on SET when defining a trigger

开发者 https://www.devze.com 2023-01-26 13:42 出处:网络
I can\'t figure out why this trigger creation syntax fails: CREATE TRIGGER mytrigger BEFORE UPDATE ON mytable

I can't figure out why this trigger creation syntax fails:

CREATE TRIGGER mytrigger BEFORE UPDATE ON mytable
FOR EACH ROW
BEGIN
    IF NEW.col1 = 0 AND NEW.col2 != '' AND NEW.col3 > 0 THEN
        SET NEW.col开发者_如何学Go1 = NEW.col3 - (10 * 60);
    END IF;
END;

MySQL says there's a syntax error at line 5, just before/on the SET statement. I'm using MySQL 5.0.27. I can't see what's wrong, seeing as it's pretty much identical to the example given in the manual 3/4s down.

PS: I'm entering this in the SQL tab on PhpMyAdmin. Adding "delimiter" statements doesn't help. Any clues? Thanks in advance!


I found it. Apparently PhpMyAdmin ignores MySQL's delimiter command when entered as part of an SQL query. Instead, you need to set the delimiter in a separate form field below the SQL query. I totally missed that!

0

精彩评论

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