Sarjit Delivala
Sarjit Delivala

Reputation: 577

Variable in trigger doesn't work for me

I am trying to create new trigger like this. But it gives me an error.

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 ;

This trigger gives error like this

enter image description here Please help.

Upvotes: 1

Views: 33

Answers (1)

valex
valex

Reputation: 24144

You have missed FOR EACH ROW statement

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

Upvotes: 1

Related Questions