请问如何创建游标,然后通过游标在方法中返回一张表的数据。

解决方案 »

  1.   

    declare
    cursor c_1 is select * from test where ..;
    begin 
     for cur1 in c_1 loop
      dbms_output.put_line(cur1.id);
     end loop;
    end;你google一下吧,应该能找到很多你需要的资料
      

  2.   

    建立存储过程,通过游标返回数据:
    create or replace package FirstPage is  -- Public type declarations
      type outlist is REF CURSOR;
     
      Procedure getSeniorHighSchool(
           maxrow in number,
           minrow in number,
           return_list out outlist
      );//可以定义其他end FirstPage;以上是packages的定义。下面是package body的定义了 create or replace package body FirstPage is --高中
      Procedure getSeniorHighSchool(
           maxrow in number,
           minrow in number,
           return_list out outlist
      )as
     
      begin
      
      
         open return_list
        
            for
           
              select * from (select a.*,rownum rnum from (
              
                //业务语句
              ) a where rownum<=maxrow) where rnum >=minrow;
              
        
        
      end;//抒写其他过程end FirstPage;