repeat
fetch .....
until 0 end;
大概核心是 cursor遍历完 所以就自动终止重复了 用了until 0 .
但是运行时出错了
报错信息:
1318 - Incorrect number of arguments for PROCEDURE lands3.pro_trade_del; expected 1, got 0Mysql版本5.6
fetch .....
until 0 end;
大概核心是 cursor遍历完 所以就自动终止重复了 用了until 0 .
但是运行时出错了
报错信息:
1318 - Incorrect number of arguments for PROCEDURE lands3.pro_trade_del; expected 1, got 0Mysql版本5.6
create PROCEDURE pro_lands_rand()
BEGIN
declare t double;
declare str varchar(20);
declare cur_lands_landNo cursor for select landNo from lands;
open cur_lands_landNo;
REPEAT
fetch cur_lands_landNo into str;
set t=RAND();
if t>0.8 THEN
update lands set village="升西村" where landNo=str;
else
if t>0.4 THEN
update lands set village="石牛村" where landNo=str;
else
update lands set village="上马村" where landNo=str;
end if;
end if;
UNTIL 0
END REPEAT;
CLOSE cur_lands_landNo;
END
$$
永远在执行不会结束的。