触发错误

时间:2017-03-30 08:37:05

标签: mysql

有人可以告诉我这个触发器有什么问题吗?我花了1个小时试图解决它,但遗憾的是没有成功,谢谢。

DELIMITER $$
CREATE TRIGGER  `pt_hotels_zero_check`BEFORE INSERT ON pt_hotels
FOR EACH ROW
BEGIN
IF(pt_hotels.touroperator_of = 0) THEN
    SIGNAL '45000'
    SET MESSAGE_TEXT = '0 value not allowed';
END IF; 
END$$
DELIMITER ;

我收到此错误:

#1064 - You have an error in your SQL syntax; check the manual that    corresponds to your MariaDB server version for the right syntax to use near ''45000'
    SET MESSAGE_TEXT = '0 value not allowed';
END IF; 

END'在第5行

1 个答案:

答案 0 :(得分:4)

SIGNAL语句的正确语法是:

SIGNAL SQLSTATE '45000'
  SET MESSAGE_TEXT = '0 value not allowed';

请参阅以下文档: https://dev.mysql.com/doc/refman/5.5/en/signal.html