1, 建立儲存過程
delimiter $$
use `test`$$
drop procedure if exists `proc_style10_t`$$
use `test`$$
create procedure test.proc_style10_t()
begin
declare v_cmp_id int;
declare v_rpt_id int;
declare _done int default 0;
declare cur_style10 cursor for select distinct cmp_id, rpt_cd from
csf.tmp_excel_data ted , csf.ms_report mr where ted.rpt_cd = mr.rpt_index
and mr.rpt_style_type = 10
and mr.delete_accnt_id is null;
open cur_style10;
repeat
fetch cur_style10 into v_cmp_id, v_rpt_id;
if not _done then
select v_cmp_id,v_rpt_id;
end if;
until _done end repeat;
close cur_style10;
end;
2,呼叫儲存過程
call test.proc_style10_t();
3,結果如下:
'495' '213'
'496' '217'
mysql游標處理
delimiter drop procedure if exists proc cur create procedure proc cur begin declare done int default 0 declare myid int declare cur1 cursor for select...
mysql游標遍歷迴圈 插入資料
begin declare no more record int default 0 declare insertcolumn varchar 18 declare cur record cursor for select insertparam from testtable declare con...
ORACLE 游標遍歷
created on 2011 10 9 by huchangkun declare local variables here cursor c event is select t.eventname from t event t temp t event.eventname type begin ...