SQL Trigger (as) is not a valid entry into this position. Error - MySQL

I'm not sure why I keep getting

an error in line number 3. (as) is not a valid input 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
+4
source share
1 answer

You need to add DELIMITER:

Try it.

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 ;
+3
source

Source: https://habr.com/ru/post/1696265/


All Articles