How to test an Oracle Stored Procedure with RefCursor return type?

Ryan Fisch picture Ryan Fisch · Jul 21, 2011 · Viewed 217.5k times · Source

I'm looking for a good explanation on how to test an Oracle stored procedure in SQL Developer or Embarcardero Rapid XE2. Thank you.

Answer

Justin Cave picture Justin Cave · Jul 21, 2011

Something like

create or replace procedure my_proc( p_rc OUT SYS_REFCURSOR )
as
begin
  open p_rc
   for select 1 col1
         from dual;
end;
/

variable rc refcursor;
exec my_proc( :rc );
print rc;

will work in SQL*Plus or SQL Developer. I don't have any experience with Embarcardero Rapid XE2 so I have no idea whether it supports SQL*Plus commands like this.