create or replace procedure test as str_l_errmsg varchar2(3800); --读取read_flag=1的所有记录
cursor cur_headinfo is select id from table1 a where a.read_flag=1; i_l_count pls_integer;begin update chdsc.edi_i_headinfo a set read_flag = 2 where read_flag = 1; --循环读取cur_headinfo中信息
for rec_hi in cur_headinfo loop
begin
..........
end;
end loop;end test;
cursor cur_headinfo is select id from table1 a where a.read_flag=1; i_l_count pls_integer;begin update chdsc.edi_i_headinfo a set read_flag = 2 where read_flag = 1; --循环读取cur_headinfo中信息
for rec_hi in cur_headinfo loop
begin
..........
end;
end loop;end test;
str_l_errmsg varchar2(3800);
i_l_count pls_integer;
begin
update chdsc.edi_i_headinfo a set read_flag = 2 where read_flag = 1;
--循环读取cur_headinfo中信息
for rec_hi in (select id from table1 a where a.read_flag=1) loop
............
end loop;
end test;前面定义的语句没啥用
去掉,进可以进了,游标是当他要用的时候才去读取表的
或者直接按照 for 变量 in (查询语句)loop end loop;
这种就不需要定义游标啦 是隐式游标也不需要close和open2.你在游标读取前 已经把read_flag = 1的记录更新了 所以你读取的记录数是0