简体   繁体   中英

MySql trigger not working, syntax error

I have tried to create the following trigger but it is not working:

delimiter //
CREATE TRIGGER DeleteFeature
AFTER DELETE ON Features
FOR EACH ROW BEGIN        
    IF (OLD.FeatureID IN (SELECT FeatureID FROM GroupFeatures)) THEN
      INSERT INTO DeletedFeatures VALUES (OLD.FeatureID, OLD.FeatureName, OLD.FeatureDescription);
    END IF;
END; 
//

It is giving the following error:

"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '//' at line 8 "

Any ideas what the problem could be?

Have you checked by removing the semi-colon and add $$ after the END

DELIMITER $$
CREATE TRIGGER DeleteFeature
AFTER DELETE ON Features
FOR EACH ROW 
  BEGIN        
    IF (OLD.FeatureID IN (SELECT FeatureID FROM GroupFeatures)) THEN
      INSERT INTO DeletedFeatures VALUES (OLD.FeatureID, OLD.FeatureName OLD.FeatureDescription);
    END IF;
  END $$
DELIMITER ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM