时间:2021-07-01 10:21:17 帮助过:2人阅读
打开游标
循环所有的行
循环结束
关闭游标
DELIMITER $$
USE `kubauser`$$
DROP PROCEDURE IF EXISTS `cursortest`$$
CREATE DEFINER=`coo8new`@`%` PROCEDURE `cursortest`(OUT a VARCHAR(50),OUT b VARCHAR(50))
BEGIN
DECLARE _outuserid VARCHAR(50);
DECLARE _kubauserid VARCHAR(50);
DECLARE flag INT;
DECLARE update_cursor CURSOR
FOR
SELECT outuserid,kubauserid FROM ecuser_cooperationuser;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET flag=1;
SET flag=0;
OPEN update_cursor;
REPEAT /*循环*/
FETCH update_cursor INTO _outuserid,_kubauserid;
SET a=_outuserid;
SET b=_kubauserid;
/*update set where*/
UNTIL flag
END REPEAT;
CLOSE update_cursor ;
END$$
DELIMITER ;
[转]MySQL游标的使用
标签: