4

I am not sure why I am keep getting

the error on line number 3. (as) is not a valid input at this position?

CREATE TRIGGER PendingPublish 
AFTER INSERT ON TopicPending
    AS
BEGIN
IF NEW.TopicApproved = 'YES' THEN
INSERT INTO Topics (Title,Description,Question1,Qustion2,Question3,Question4,UserID)
VALUES (NEW.Title,NEW.Description,NEW.Question1,NEW.Question2,NEW.Question3,NEW.Question4,NEW.UserID);
END IF;
END
DineshDB
  • 5,998
  • 7
  • 33
  • 49
sach jot
  • 570
  • 4
  • 16

1 Answers1

3

You have to add DELIMITER:

Try this.

DELIMITER $$
CREATE TRIGGER PendingPublish 
AFTER INSERT ON TopicPending
FOR EACH ROW
BEGIN
    IF NEW.TopicApproved = 'YES' THEN
    INSERT INTO Topics (Title,Description,Question1,Qustion2,Question3,Question4,UserID)
    VALUES (NEW.Title,NEW.Description,NEW.Question1,NEW.Question2,NEW.Question3,NEW.Question4,NEW.UserID);
END IF;
END$$
DELIMITER ;
DineshDB
  • 5,998
  • 7
  • 33
  • 49
  • 1
    This doesn't syntax there should be a FOR EACH ROW clause before the begin https://dev.mysql.com/doc/refman/5.7/en/create-trigger.html – P.Salmon Apr 18 '18 at 07:17