MYSQL存储过程游标错误:No data - zero rows fetched, selected, or processed

阅读更多
游标FETCH获取为空时应该及时退出循环:
DROP PROCEDURE IF EXISTS delete_Menu;  
DELIMITER $$ 
CREATE PROCEDURE delete_Menu( IN menuCode VARCHAR(200))
BEGIN  
	DECLARE done INT DEFAULT 0; 
	DECLARE userCode VARCHAR(20);
	DECLARE cur_user CURSOR FOR SELECT code FROM user; 
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;  
	
	OPEN cur_user;
	out_loop:
		LOOP
		  FETCH cur_user INTO userCode;
			IF done =1 THEN
				LEAVE out_loop;
			END IF;
			CALL  deleteMenu(menuCode,userCode);	
			SET done = 0;
	END LOOP out_loop;
	CLOSE cur_user;
	
END 


你可能感兴趣的:(mysql,producure,cursor)