RT, 
存储过程有没有类似java ,当遇到一定的条件的时候,我需要退出本次循环,进行下次循环的功能???
谢谢

解决方案 »

  1.   

    可以通过exception方式来终止本次循环,进入下一次循环。
      

  2.   

    exit退出循环,结合其它条件可以达到进行下次循环的功能。
      

  3.   

    你exit就退出整个loop了。如何再次loop?
      

  4.   

    将剩余的语句包括在一个if 语句中,if的条件设置为你希望continue的条件
      

  5.   

    declare
      i integer;
    begin
      i := 0;
      while i < 10  loop
        if i = 3 then 
         -- i := i +1;
          goto end_loop;
        end if;
        dbms_output.put_line(i);
        
        <<end_loop>>
        i:= i+1;
      end loop;
    end;
      

  6.   

    定义一个异常处理块,并把它放到循环体的最后,在需要continue的时候抛出这个异常。
      

  7.   

    oracle 11g已提供continue;
    oracle 10g及以下,使用goto来替代,例如SQL> set serveroutput on;
    SQL> declare
      2  begin
      3    for i in 1..10 loop
      4      if mod(i,2)=0 then
      5        goto next;
      6      end if;
      7      dbms_output.put_line(i); 
      8      <<next>>
      9      null;
     10    end loop;
     11  end;
     12  /
    1
    3
    5
    7
    9PL/SQL 过程已成功完成。SQL> 注意:<<next>>标签后的null;语句不可少,因为goto标签后必须紧接着一个执行语句
      

  8.   

    简单的说,没有。
    一般的做法是用goto代替。
      

  9.   

    create or replace procedure test_proc
    as
    v_number number:=0;
    begin
    for i in 1..100 loop
    begin
    select num into v_number from tab_test where id=to_char(i);
    exception 
    when no_data_found then
    null;--有异常时,什么也不执行
    end;
    end loop;
    end test_proc;
    就向java中也有goto一样,但在实际的开发中又有谁用goto呢?东跳西跳的,最后把自己给跳晕了。
    不建议使用goto(个人看法)。