日期:2014-05-17  浏览次数:20983 次

PL/SQL中循环不满足条件怎么跳出当前循环继续
PL/SQL中循环不满足条件怎么跳出当前循环继续 就是像Java中一样 不满足条件 break 但是可以继续循环

------解决方案--------------------
loop 中增加if else 进行判断~~~·~
------解决方案--------------------
next关键字可以解决你的问题
------解决方案--------------------
用if else 或者用goto
------解决方案--------------------
用IF else goto直接解决你的问题。希望能够帮到你吧
------解决方案--------------------
SQL code

--原来是这样的
loop
  select col into v_col from tbname ;
end loop ;

--改成这样的,就会把异常吃掉了,但是别忘了异常处理,起码也应该记录一下吧.
loop
  begin
    select col into v_col from tbname ;
  exception 
    when no_data_found then 
      --exception handle 
    when value_error then
      --exception handle
  end ;
end loop;

------解决方案--------------------

SQL code

loop
  begin
    select col into v_col from tbname ;
  exception 
    when no_data_found then 
      --exception handle 
    when value_error then
      --exception handle
    when other then
      --exception handle
  end ;
end loop;

------解决方案--------------------
定义标签,然后使用goto,列子如下:
declare
nT integer;
begin
-- <<label_name>>
nT := 0;
<<label_1>>
loop
if(nT > 100) then
exit;
end if;
nT := nT + 1;
if(mod(nT,2)=1) then
goto label_1;
end if;

dbms_output.put_line(nT);
end loop;
end;

在11g中貌似实现了continue
------解决方案--------------------
goto 就可以了