转移SQLserver的存储过程到Oracle中,Oracle中不支持break,continue,fetch next等功能,
求各位高手指导下,Oracle中怎么实现这些功能,越具体越好

解决方案 »

  1.   

    在oracle存储过程里,如果要中断代码执行可以用raise_application_error(),或者return
    退出循环用exit
    fetch next不知道是什么意思
      

  2.   

    你那样的话 是完全跳出循环 我现在需要的是跳出当前循环继续循环,fetch next 是执行游标的下一个记录
      

  3.   

    oracle中有fetch cursor into 变量,用在循环中取当前变量,应该可以达到fetch next的效果
    exit是退出当前循环吧
      

  4.   

    刚试了下,exit确实是退出所有循环
      

  5.   

    不清楚你想实现什么样的功能,我想有些东西即使oracle中没有对应的东西,也能通过其他的方式去实现
      

  6.   

    我用的就是游标 我现在要做的是 
    LOOP
    if 条件
     跳出当前循环
     游标指向下一个记录
    END if
    END LOOP其中要用到类似SQLserver中break,continue,fetch next功能
      

  7.   

    --oracle游标是这样用的
    declare
     cursor v_cur is select  1 from dual;
     aa number;
    begin
     open v_cur;
     fetch v_cur into aa;
     while v_cur %found loop
      --处理语句
      fetch v_cur into aa;
     end loop;
     close v_cur;
    end;
    /
      

  8.   

    in pro*c/c++ document6.6 Scrollable CursorsA scrollable cursor is a work area where Oracle executes SQL statements and stores information that is processed during execution.When a cursor is executed, the results of the query are placed into a a set of rows called the result set. The result set can be fetched either sequentially or non-sequentially. Non-sequential result sets are called scrollable cursors.A scrollable cursor enables users to access the rows of a database result set in a forward, backward, and random manner. This enables the program to fetch any row in the result set. See Oracle Call Interface Programmer's Guide, Release 9.2.0.
    6.6.1 Using Scrollable CursorsThe following statements let you define and manipulate a scrollable cursor.
    6.6.1.1 DECLARE SCROLL CURSORYou can use the DECLARE <cursor name> SCROLL CURSOR statement to name the scrollable cursor and associate it with a query.
    6.6.1.2 OPENYou can use the OPEN statement in the same way as in the case of a non-scrollable cursor.
    6.6.1.3 FETCHYou can use the FETCH statement to fetch required rows in a random manner. An application can fetch rows up or down, first or last row directly, or fetch any single row in a random manner.The following options are available with the FETCH statement.   1.      FETCH FIRST      Fetches the first row from the result set.
       2.      FETCH PRIOR      Fetches the row prior to the current row.
       3.      FETCH NEXT      Fetches the next row from the current position. This is same as the non-scrollable cursor FETCH.
       4.      FETCH LAST      Fetches the last row from the result set.
       5.      FETCH CURRENT      Fetches the current row.
       6.      FETCH RELATIVE n      Fetches the nth row relative to the current row, where n is the offset.
       7.      FETCH ABSOLUTE n      Fetches the nth row, where n is the offset from the start of the result set.The following example describes how to FETCH the last record from a result set.EXEC SQL DECLARE emp_cursor SCROLL CURSOR FOR
    SELECT ename, sal FROM emp WHERE deptno=20;
    ...
    EXEC SQL OPEN emp_cursor;
    EXEC SQL FETCH LAST emp_cursor INTO :emp_name, :sal;
    EXEC SQL CLOSE emp_cursor;
      

  9.   

    能不能举例具体说明下如何实现SQLserver的break,continue,fetch next功能。
      

  10.   

     while v_cur >10 loop
      --处理语句
      --break没用,但这样应该就退出循环了。
      v_cur := 9;
     end loop;
      

  11.   

    while v_cur >10 loop 
      --处理语句 
      exit;---这样也行
    end loop;