我需要在MySQL中声明变量。这就是我现在所拥有的。
CREATE TRIGGER upd
BEFORE UPDATE ON chats FOR EACH ROW
BEGIN
DECLARE my_cursor CURSOR FOR SELECT name FROM messages;
END
逻辑上,它接缝好了。但是有一个奇怪的错误 即
SQL查询:
CREATE TRIGGER upd
BEFORE UPDATE ON chats FOR EACH ROW
BEGIN
DECLARE my_cursor CURSOR FOR SELECT name FROM messages;
MySQL说:
#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 4
答案 0 :(得分:3)
这很有效。当它被关闭时很乐意删除它。
它只是没有分隔符包装块。
drop trigger if exists upd;
delimiter $$
CREATE TRIGGER upd
BEFORE UPDATE ON chats FOR EACH ROW
BEGIN
DECLARE vapenid INT;
END;
$$
delimiter ;