我试图创建以下触发器,但它不起作用:
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;
//
出现以下错误:
"#1064 - 您的SQL语法出错;检查与您的MySQL服务器版本对应的手册,以便在' //'附近使用正确的语法。在第8行"
任何想法可能是什么问题?
答案 0 :(得分:0)
您是否通过删除分号进行检查,并在$$
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 ;