declare v_total int default 0;
declare no_list cursor for select no,id from table;
select count(1) into v_total from table;
open no_list;
loop1:loop
-- mysql cursor 不会自动退出cursor 循环,需自行增加条件判断
IF i > v_total THEN LEAVE loop1; end if;
-- 根据游标当前指向的一条数据
fetch no_list into v_no , v_id ;
--do operation here
set i = i+1;
end loop;
close no_list;