当前位置:Gxlcms > mysql > cursor-mysql中存储过程无法创建成功

cursor-mysql中存储过程无法创建成功

时间:2021-07-01 10:21:17 帮助过:9人阅读

mysqlcursor存储

delimiter $$
BEGIN
DECLARE iti varchar(25);
declare maj varchar(25);
declare cla tinyint(1);
declare buffer tinyint(1);
declare grd enum('2014级','2012级','2013级');
declare mycur CURSOR for select institude,major,grade,class from show_information;
open mycur;
fetch mycur into iti,maj,grd,cla;
while(iti is not null)DO
select buffer=count(*) from show_information where institude=iti and major=maj and grade=grd and class=cla;
update statistics set classnum=buffer where institude=iti and major=maj and grade=grd and class=cla;
fetch mycur into iti,maj,grd,cla;
end while;
close mycur;
END
$$
delimiter ;

人气教程排行