表校验
val
----
5705
5704
5703
5702
5701
存储过程
BEGIN
DECLARE x INT;
DECLARE done INT DEFAULT FALSE;
DECLARE myType INT;
DECLARE cur1 CURSOR FOR select val from checkval;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
SET x = 10;
WHILE x >= 2 DO
##############
OPEN cur1;
read_loop: LOOP
IF done THEN
LEAVE read_loop;
END IF;
FETCH cur1 INTO myType;
insert into myType values (myType);
END LOOP read_loop;
CLOSE cur1;
SET x = x-1;
##################
END WHILE;
END
电流输出
5705
5704
5703
5702
5701--Loops only twice
5705
5704
5703
5702
5701
期望的输出
5705 - Loops 8 times
5704
5703
5702
5701
5705
5704
5703
5702
5701
5705
5704
5703
5702
5701
5705
5704
5703
5702
5701
5705
5704
5703
5702
5701
5705
5704
5703
5702
5701
5705
5704
5703
5702
5701
5705
5704
5703
5702
5701
为什么即使我指定了一个从 开始10
和结束的 while 循环2
,我的输出是否只在目标表中循环了两次。我希望看到它重复8次。你能帮忙吗?