我在MySql Workbench中出现语法错误,但似乎找不到它... 我的触发器正确吗?
CREATE TRIGGER after_delete_user AFTER UPDATE
ON users FOR EACH ROW
BEGIN
IF NEW.deletionDate != NULL
THEN
DELETE FROM requests WHERE user_id = OLD.user_id;
DELETE FROM appointments WHERE user_id = OLD.user_id;
END IF;
END;
谢谢!
答案 0 :(得分:1)
需要将定界符定义为;
以外的其他内容。最后将其重新定义为null
。要比较IS NOT NULL
的值,我们需要使用DELIMITER $$
CREATE TRIGGER after_delete_user AFTER UPDATE
ON users FOR EACH ROW
BEGIN
IF NEW.deletionDate IS NOT NULL
THEN
DELETE FROM requests WHERE user_id = OLD.user_id;
DELETE FROM appointments WHERE user_id = OLD.user_id;
END IF;
END$$
DELIMITER ;
"/bin/sleep 3 && /usr/bin/beanstalkd -b /binlog"