我需要通过 mysql 脚本创建触发器
CREATE TRIGGER sync_new_oauth_sessions
AFTER INSERT
ON oauth_sessions FOR EACH ROW
BEGIN
SET @s = 'INSERT INTO oauth_sessions_new(id, client_id, owner_type, owner_id, owner_id_new) VALUES (?, ?, ?, ?, CAST(NULLIF(?,'''') AS UNSIGNED))';
-- INSERT INTO oauth_sessions_new(id, client_id, owner_type, owner_id, owner_id_new) VALUES (NEW.id, NEW.client_id, NEW.owner_type, NEW.owner_id, CAST(NULLIF(NEW.owner_id,'') AS UNSIGNED));
PREPARE stmt2 FROM @s;
SET @sid = NEW.id;
SET @s_client_id = NEW.client_id;
SET @s_owner_type = NEW.owner_type;
SET @s_owner_id = NEW.owner_id;
SET @s_owner_id_new = NEW.owner_id;
EXECUTE stmt2 USING @sid, @s_client_id, @s_owner_type, @s_owner_id, @s_owner_id_new;
END
这是脚本的内容。我越来越:
Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
我不明白我做错了什么。如果我这样做\'\'
了,我也会遇到同样的问题。
谢谢