-- 创建:游标
DROP PROCEDURE IF EXISTS _grouping;
CREATE PROCEDURE _grouping()
BEGIN
-- 定义:接收游标数据的变量
DECLARE id INT;
DECLARE pid INT DEFAULT 2;
-- 定义:游标数据源
DECLARE cur CURSOR FOR SELECT gid FROM category WHERE pgid = pid;
-- 启动游标
OPEN cur;
-- 开始游标逻辑
REPEAT
FETCH cur INTO id;
INSERT INTO grouping(categoryid,groupid) VALUES (id,pid);
-- 关闭游标
CLOSE cur;
END
异常提示:
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 'END' at line 16
你这是语法异常吧 游标没事啊 END 后面加上存储过程的名字和分号呀
END _grouping;