触发器中的变量对我不起作用

时间:2014-04-22 06:02:12

标签: mysql triggers

我正在尝试创建这样的新触发器。但它给了我一个错误。

DELIMITER $$
CREATE TRIGGER email_postid_truncate BEFORE INSERT
ON email_postid
BEGIN

SET @cnt = (SELECT count(*) FROM email_postid WHERE status='Remaining');
IF @cnt = 0 THEN

    --My query

END IF;
END $$

DELIMITER ;

此触发器会出现如下错误

enter image description here 请帮忙。

1 个答案:

答案 0 :(得分:1)

您错过了FOR EACH ROW statement

CREATE TRIGGER email_postid_truncate BEFORE INSERT
ON email_postid
FOR EACH ROW
BEGIN
....