我有这两个触发器,但两者都给出了“那么”的语法错误,我无法弄清楚原因。所有的表都是在调用它们时依此类推,我以分隔符开始:
CREATE TRIGGER capacity
AFTER INSERT ON Participants
FOR EACH ROW
BEGIN
IF (NEW.status = 'a' AND
(SELECT capacity FROM rooms WHERE room = NEW.PID) > (SELECT COUNT(*) FROM Participants WHERE meetID = NEW.meetID) THEN DELETE FROM Participants WHERE PID = NEW.PID AND meetID = NEW.meetID;
END IF;
END $$
CREATE TRIGGER iraLikesBeer
AFTER INSERT ON Meetings
FOR EACH ROW
BEGIN
IF ( NEW.what LIKE '%beer%' AND 'ira' NOT IN(SELECT pid FROM Participants WHERE meetid = 'NEW.meetid') THEN
INSERT INTO Participants
VALUES (NEW.meetID,'ira', 'u');
END IF;
END $$
答案 0 :(得分:0)
您的两个触发器定义都有不平衡的括号。
IF (NEW.status = 'a' AND (SELECT ...) > (SELECT ...) THEN ...
^
第一个开场白没有关闭的人。
第二次触发时存在同样的问题。