我想创建一个使用新值插入的前插入触发器,以检查触发器是否应该让插入发生或在某些条件下停止它。我真的找不到该触发器的正确语法,但这是足够明确的伪代码:
CREATE TRIGGER my_first_trigger BEFORE INSERT COMMENT VALUES(comment, #commentPIID, #commentUserID)
FOR EACH ROW
BEGIN
IF
(SELECT USER.ID
FROM USER LEFT JOIN PI_REMINDER ON PI_REMINDER.userID == USER.ID
WHERE PI_REMINDER.ID == commentPIID && USER.ID == commentUserID) IS NOT NULL)
OR
((SELECT userID
FROM pishared
WHERE PIID == commentPIID && userID ==commentUserID && acceot == 1) IS NOT NULL)
THEN
INSERT INTO COMMENT VALUES(comment, #commentPIID, #commentUserID)
END IF;
END;
有人可以告诉我在那个伪代码案例中使用的正确语法吗?