Domanda

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.

È stato utile?

Soluzione

You have missed FOR EACH ROW statement

CREATE TRIGGER email_postid_truncate BEFORE INSERT
ON email_postid
FOR EACH ROW
BEGIN
....
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top