Home » SQL & PL/SQL » SQL & PL/SQL » Refrence cursors as output params
Refrence cursors as output params [message #2086] Thu, 20 June 2002 06:04 Go to next message
Mike Nibeck
Messages: 49
Registered: May 2002
Member
Our middleware engineers have asked that we use refrence cursors to pass back record sets from our stored procs. This has something to do with their .NET framework they are putting together. Anyway, this isn't a problem on the stored proc side, but I had a quick question about testing tehse stored procs in PL/SQL.

How can I write PL/SQL test procedures that will accept a returned reference cursor as an output parameter from a stored proc and display the values in the cursor?

- Mike
Re: Refrence cursors as output params [message #2092 is a reply to message #2086] Thu, 20 June 2002 09:44 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Here's how you can see the cursor in SQL*Plus:

sql>var rc refcursor
sql>exec foo.proc(:rc)
 
PL/SQL procedure successfully completed.
 
sql>print rc
 
LAST_NAME
------------------------------
Wallis
Flores
Arenas
Cummings


And if you want a procedure to show the output using DBMS_OUTPUT:

create or replace procedure footest
is
  v_rc         foo.rc;
  v_last_name  varchar2(30);
begin
  foo.proc(v_rc);
  loop
    fetch v_rc into v_last_name;
    exit when v_rc%notfound;
    dbms_output.put_line(v_last_name);
  end loop;  
  close v_rc;
end;
/


And then in SQL*Plus:

sql>set serveroutput on
sql>exec footest
Wallis
Flores
Arenas
Cummings
 
PL/SQL procedure successfully completed.
Previous Topic: Error: ORA-01034: ORACLE not available
Next Topic: Oracle error re: null dates returned on a select - into sql structure in a cobol program
Goto Forum:
  


Current Time: Fri Apr 26 13:08:51 CDT 2024