MySQL 5.5。创建触发器时出错

时间:2014-12-27 01:44:53

标签: mysql triggers

我尝试在mysql 5.5中创建触发器以防止在非空字段中插入空字符串:

CREATE TRIGGER check_empty_fields
    BEFORE INSERT ON customer_address
        FOR EACH ROW
        BEGIN
        IF new.customer_name = '' THEN SET new.customer_name = NULL ;
END IF;

        IF new.customer_address = '' THEN SET new.customer_address = NULL ;
END IF;

END; 

但是我收到了这个错误:

MySQL said: Documentation

#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 '' at line 5 

0 个答案:

没有答案