mysql 储存过程游标出错?
SQL code
BEGIN
#Routine body goes here...
#INSERT china into (name,parentid,path) values ('中国',0,'0,1,')
DECLARE p_cursor CURSOR FOR select Name from province;
DECLARE n varchar(25);
OPEN p_cursor;
CURSOR_loop:LOOP
FETCH p_cursor INTO n;
CLOSE p_cursor;
END;
------解决方案--------------------
DELIMITER $$
CREATE PROCEDURE QQW()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE n VARCHAR(25);
DECLARE p_cursor CURSOR FOR SELECT NAME FROM province;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN p_cursor;
FETCH p_cursor INTO n;
WHILE done=0 DO
FETCH p_cursor INTO n;
END WHILE;
CLOSE p_cursor;
END$$
DELIMITER ;