日期:2014-05-17 浏览次数:21221 次
set serveroutput on
--dbms_output.enable(1000000)
set serveroutput on size 10000
declare
v_count int:=0;
v_enttaxcode varchar2(50);
begin
loop
update cominfo set iscalculate=2 where e_taxadmin='陈云霞';--满足这个条件的一共有24条记录
begin
select e_enttaxcode into v_enttaxcode from tax.cominfo where iscalculate=2 and rownum<2;
exception
when others then
null;
end;
if v_enttaxcode is not null then
begin
dbms_output.put_line(v_enttaxcode);
end;
else
begin
dbms_output.put_line('输出完毕');
exit;
end;
end if;
update tax.cominfo set iscalculate=0 where e_enttaxcode=v_enttaxcode;
select count(e_enttaxcode) into v_count from cominfo where iscalculate=2;
dbms_output.put_line(v_count);
v_enttaxcode:=null;
end loop;
end;
/
update tax.cominfo set iscalculate=0 where e_enttaxcode=v_enttaxcode;
set serveroutput on
--dbms_output.enable(1000000)
set serveroutput on size 10000
declare
v_count int:=0;
v_enttaxcode varchar2(50);
begin
loop--请问你加循环的作用是什么?并且该循环没有退出的条件(即:你说的死循环)
update cominfo set iscalculate=2 where e_taxadmin='陈云霞';--满足这个条件的一共有24条记录
commit;--提交一下
begin
select e_enttaxcode into v_enttaxcode from tax.cominfo where iscalculate=2 and rownum<2;
exception
when others then
null;
end;
if v_enttaxcode is not null then
begin
dbms_output.put_line(v_enttaxcode);
end;
else
begin
dbms_output.put_line('输出完毕');
exit;
end;
end if;
update tax.cominfo set iscalculate=0 where e_enttaxcode=v_enttaxcode;
commit;--提交一下
select count(e_enttaxcode) into v_count from cominfo where iscalculate=2;
dbms_output.put_line(v_count);
v_enttaxcode:=null;
end loop;--
end;
/
------解决方案--------------------
你的LOOP
END LOOP之间根本没有满足退出的条件,当然无限循环了
虽然你的if v_enttaxcode is not null then
begin
dbms_output.put_line(v_enttaxcode);
end;
else
begin
dbms_output.put_line('输出完毕');
exit;
end;
end if;
但是当v_enttaxcode 非空的时候就一直循环了,
而且你的查询只有得到一条记录select e_enttaxcode into v_enttaxcode from tax.cominfo where iscalculate=2 and rownum<2,为什么要循环?十分不解,把LOOP 和END LOOP去掉修改下即可