您的位置:首页 > 数据库 > MySQL

关于mysql游标的一个例子

2011-04-11 09:47 447 查看
declare fetchSeqOk boolean; ## define the flag for loop judgement
declare _seqname varchar(50); ## define the varient for store the data
declare _value bigint(20);
declare fetchSeqCursor cursor for select seqname, value from sys_sequence;## define the cursor
declare continue handler for NOT FOUND set fetchSeqOk = true; ## define the continue handler for not found flag
set fetchSeqOk = false;

open fetchSeqCursor;
fetchSeqLoop:Loop
if fetchSeqOk then
leave fetchSeqLoop;
else
fetch cursor into _seqname, _value;
begin

declare fetchSeqOk boolean default 'inner';
declare cursor2 cursor for select .... from ...;## define the cursor
declare continue handler for NOT FOUND set fetchSeqOk = true; ## define the continue handler for not
set fetchSeqOk = false;
open cursor2;
fetchloop2 loop
if fetchSeqOk then
else

end if;

end loop;
close cursor2;
end;
end if;

end Loop;
close fetchSeqCursor;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: