oracle 返回的select 结果集的proc 如何写?
哪位给个例子看看?
晚上结贴谢谢!
要是自己写出来了就贴出来。

解决方案 »

  1.   


    create or replace procedure myProc
    as
    temp table%rowType;
    mycur as select * from table;
    begin
     open mycur;
     fetch mycur to temp;
      while mycur%notfount loop
         DBMS_oupput.put_Line(temp.colName);
      end loop;
      close mycur;
    end;
      

  2.   


    --修正一下
    CREATE OR new PACKAGE SELECT_EMPLOYEES_JOBS AS
    TYPE T_CURSOR IS REF CURSOR;
    PROCEDURE GetEmployeesAndJobs (
    cur_Employees OUT T_CURSOR, 
    cur_Jobs OUT T_CURSOR
    );
    END SELECT_EMPLOYEES_JOBS;包正文如下所示:CREATE OR new PACKAGE BODY SELECT_EMPLOYEES_JOBS AS
    PROCEDURE GetEmployeesAndJobs
    (
    cur_Employees OUT T_CURSOR,
    cur_Jobs OUT T_CURSOR
    )
    IS
    BEGIN
    -- return all EMPLOYEES records
    OPEN cur_Employees FOR
    SELECT * FROM Employees;-- return all JOBS records
    OPEN cur_Jobs FOR
    SELECT * FROM Jobs;
    END GetEmployeesAndJobs;
    END SELECT_EMPLOYEES_JOBS;
      

  3.   

    create or replace procedure procedure_name
    (
     --define in/out parameter)
    as
    --define var
    begin--return result connection
    open rcursor for
    select * from table_name where conditiion.............;end;
      

  4.   

    先在Oracle中写个存储过程,返回结果集,再在proc中调用。请参考:http://topic.csdn.net/u/20081026/21/04c0693f-41df-42fd-ac60-a04122232ac2.html