DELIMITER $$
DROP TRIGGER IF EXISTS TRIGGER_BEFORE_USERS_MAUALEXPIRY_USEREXPIRAY_UPDATE $$
CREATE TRIGGER TRIGGER_BEFORE_USERS_MAUALEXPIRY_USEREXPIRAY_UPDATE
BEFORE UPDATE ON USERS
FOR EACH ROW
BEGIN
IF @DISABLE_TRIGGERS IS NULL THEN
IF NOT (NEW.MANUALEXPIRATIONDATE <=> OLD.MANUALEXPIRATIONDATE) THEN
SET NEW.CUSTOMFIELD2 = NEW.MANUALEXPIRATIONDATE;
IF NOT(NEW.USEREXPIRYDATE <=> OLD.USEREXPIRYDATE) THEN
SET NEW.CUSTOMFIELD3 = NEW.USEREXPIRYDATE;
END IF;
END IF;
END$$
DELIMITER ;
错误代码:1064。您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第17行的''附近使用正确的语法
答案 0 :(得分:0)
CREATE TRIGGER TRIGGER_BEFORE_USERS_MAUALEXPIRY_USEREXPIRAY_UPDATE
BEFORE UPDATE ON USERS
FOR EACH ROW
BEGIN
IF @DISABLE_TRIGGERS IS NULL THEN
IF NOT (NEW.MANUALEXPIRATIONDATE <=> OLD.MANUALEXPIRATIONDATE) THEN
SET NEW.CUSTOMFIELD2 = NEW.MANUALEXPIRATIONDATE;
END IF;
IF NOT(NEW.USEREXPIRYDATE <=> OLD.USEREXPIRYDATE) THEN
SET NEW.CUSTOMFIELD3 = NEW.USEREXPIRYDATE;
END IF;
END IF;
END
$$