Getting a ref cursor out of a procedure

Hello,
I am having some issues getting the ref cursor out of this procedure that returns a ref cursor when given inputs.
I have included the code below and made bold the call to the package and procedure where the requested function lies. I put c2 in the first parameter because that is the out and is defined first in the procedure. Am I going about this the wrong way? I am mainly a .NET developer and am still learning the syntax of PL/SQL.
Thanks!
Jeffrey Kevin Pry
DECLARE
TYPE r_cursor IS REF CURSOR;
c2 r_cursor;
CURSOR c1
IS
SELECT *
FROM ELEMENT E
WHERE E.SUBTYPE_CD = 'PAT';
BEGIN
FOR ROW_ITEM IN c1
LOOP
PKG_DTEST.GET_CHILDREN(c2,ROW_ITEM.ELEMENT_ID,1);
FOR ROW_ITEM2 in c2
LOOP
dbms_output.put_line(ROW_ITEM2.ELEMENT_ID);
END LOOP;
END LOOP;
END;
Edited by: jeffrey.pry on Jan 21, 2011 6:01 AM

You should probably post the code of PKG_DTEST.GET_CHILDREN as well as the error you are getting. It's hard to troubleshoot without knowing all the parts and pieces.
Additionally, I see that you are using a nested FOR loop to process your data. You should rethink this. The best way to process data in Oracle is to compact it all into a single SQL statement if possible. If you are having trouble doing this please post the following and we can help.
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to get an UPDATABLE REF CURSOR from the STORED PROCEDURE

    using C# with
    ORACLE OLE DB version: 9.0.0.1
    ADO version: 2.7
    I returns a REF CURSOR from a stored procedure seems like:
    type TCursor is ref cursor;
    procedure test_out_cursor(p_Dummy in varchar, p_Cur out TCursor) is
    begin
         open p_Cur for select * from DUAL;
    end;
    I create an ADO Command object and set
    cmd.Properties["IRowsetChange"].Value = true;
    cmd.Properties["Updatability"].Value = 7;
    cmd.Properties["PLSQLRSet"].Value = 1;
    cmd.CommandText = "{CALL OXSYS.TEST.TEST_OUT_CURSOR(?)}";
    and I use a Recordset object to open it:
    rs.Open(cmd, Missing.Value,
    ADODB.CursorTypeEnum.adOpenStatic,
    ADODB.LockTypeEnum.adLockBatchOptimistic,
    (int) ADODB.CommandTypeEnum.adCmdText +
    (int) ADODB.ExecuteOptionEnum.adOptionUnspecified);
    The rs can be opened but can NOT be updated!
    I saved the recordset into a XML file and there's no
    rs:baseschema/rs:basetable/rs:basecolumn
    attributes for "s:AttributeType" element.
    Any one have idea about this?
    thanks very much

    It is not possible through ADO/OLEDB.
    Try ODP.NET currently in Beta, it is possible to update DataSet created with refcursors. You need to specify your custom SQL or SP to send update/insert/delete.
    As I remember there is a sample with ODP.NET Beta 1 just doing this.

  • Passing Ref Cursor to Oracle Stored Procedure Via C#

    Hi all,
    I am new to oracle and stuck with an issue. I have three insert stored procedures for three different tables. Two of them have multiple rows to be inserted, which is currently done via iterating through each row and insert to db in C# code. My requirement is to merge these three procedures in one and instead of iterating from C# code send table rows as (ref cursor or collection) to procedure and the procedure will handle the rest.
    I read that ref cursor only works if you're data is in database as it reference the memory but in my case data is build on client side.
    I am using Oracle 11i and ASP.Net 2.0
    Can any help me on this please?
    Edited by: 929463 on Apr 23, 2012 12:38 AM

    929463 wrote:
    I am new to oracle and stuck with an issue. I have three insert stored procedures for three different tables. Two of them have multiple rows to be inserted, which is currently done via iterating through each row and insert to db in C# code. My requirement is to merge these three procedures in one and instead of iterating from C# code send table rows as (ref cursor or collection) to procedure and the procedure will handle the rest.Why a single procedure? How is the procedure to determine the target table to insert the data into? And please - no dynamic SQL as that is 99% of the time wrong.
    A ref cursor is something that PL/SQL creates - with the purpose of passing the cursor handle to your code. This enables the actual SQL statement for that cursor to be moved from client code, into a PL/SQL stored proc. It abstracts the client from having to understand SQL, understand the data model and so on. All clients use the same PL/SQL proc and thus the same code for creating that cursor. Thus no issue of some clients getting it half right or half wrong and dealing with data inconsistencies between clients.
    The PL/SQL proc can be tuned and optimised, modified for catering for data model changes and so on. Without your client code having to be even recompiled as it is isolated against these server changes.
    For all other interaction (running PL/SQL code, doing insert/update/delete/etc SQL statements), you need to create the cursor yourself in your code.
    Also, the SQL engine only sees cursors. There are no differences between cursors. The client (e.g. PL/SQL) can call it a reference cursor, or an implicit cursor, or a DBMS_SQL cursor.. the SQL engine does not know that and does not care.
    A ref cursor is simply a special type of client interface to a SQL cursor, allowing PL/SQL to create that SQL cursor and then pass the handle of that SQL cursor to other code to consume that cursor.
    Okay, so if you want to insert data, you need in your code to create a cursor. This can be a SQL INSERT cursor - the actual insert statement. Or it can be a PL/SQL call - an anonymous PL/SQL code block that calls a stored proc that performs the insert (after applying validation and business logic).
    The cursor will have one or more bind variables. Your client will pass values for these variables and the server-side code (SQL or PL/SQL) will be executed using this as variable data.
    You can for example create a cursor as follows:
    begin
      DoFunkyInsert( :1, :2, :3 );
    end;
    {code}
    3 bind variables are expected. You can now in the client build an array for each of these variables, containing a 100 values each (total of a 100 rows to insert). Do a single execute of the cursor, and tell Oracle that the bind is actually a 100 element array.
    The complete array ships to Oracle - Oracle opens a loop and execute the cursor for each element in the array.
    This is called bulk binding.
    An alternative approach is to define the bind variable as a collection (a non-scalar value). And then code the PL/SQL procedure to open a loop and iterate through the collection/array, inserting a row per iteration.
    The binding itself is more complex as your code know needs to understand Oracle object types and be able to define an array/collection that is a valid Oracle non-scalar data type.
    The +Oracle Call Interface+ (OCI) is quite flexible in this regard. However, as you work via an abstraction layer (e.g. ADO, OleDB, ODBC, etc) your code is subject to whatever functionality this abstraction layer makes available to your code. And this is seldom includes all the power, functionality and flexibility of the (more complex) OCI itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Retrieve to forms 6i a ref cursor from a store procedure

    hi, i wanna know how to retrieving to forms 6i a ref cursor or a sys_refcursor from a function or a store procedure.
    i`ll be very gradeful if someone send me the code.
    sorry about my english, the spanish is my native languaje.

    I think you can use procedure similar to this one:
    example:
    My sample table:
    SQL> desc small_perf_table1;
    Name                                      Null?    Type
    COL1                                               NUMBER
    COL2                                               VARCHAR2(10)
    COL3                                               VARCHAR2(1)
    Simple data inside:
    SQL> select col1 from small_perf_table1
      2  where rownum < 10;
          COL1
             1
             2
             3
             4
             5
             6
             7
             8
             9
    9 rows selected.
    Create procedure which return variable sys_refcursor type:
    SQL> CREATE OR REPLACE PROCEDURE proc_cursor_test
      2  (v_cursor OUT sys_refcursor)
      3  IS
      4  BEGIN
      5   OPEN v_cursor FOR select col1 from small_perf_table1 where rownum < 10;
      6  END;
      7  /
    Procedure created.
    And here is code you can write inside forms:
    SQL> DECLARE
      2   type t_cursor IS REF CURSOR;
      3   v_cursor t_cursor;
      4   v_col1 NUMBER;
      5  BEGIN
      6   proc_cursor_test(v_cursor);
      7   LOOP
      8     FETCH v_cursor INTO v_col1;
      9     EXIT WHEN v_cursor%NOTFOUND;
    10     -- DBMS_OUTPUT.PUT_LINE(v_col1); This line is only for testing inside SQL*PLUS.
    11   END LOOP;
    12  END;
    13  /
    1
    2
    3
    4
    5
    6
    7
    8
    9
    PL/SQL procedure successfully completed.This is just an example.
    If this example does not resolve your problems then maybe you should ask your question on forms forum.
    Forms
    Peter D.

  • Problem passing REF CURSOR to JAVA STORED PROCEDURE

    Hi,
    I've written a small Java class with a static method and
    imported that into Oracle 8i. The method expects a
    java.sql.ResultSet object as parameter. According to the
    documentation of Oracle, a REF CURSOR (cursor variable) maps to
    java.sql.ResultSet in JDBC.
    The definition of the Java Stored Procedure was accepted without
    problems:
    CREATE OR REPLACE PROCEDURE RESULTSETPASSINGTESTPROC (row
    WASTypes.GenericCurType)
    as language java
    name 'sqlj.ResultSetPassingTest.testResultSetPassing
    (java.sql.ResultSet)';
    WASTypes is a package containing the definition of the generic
    cursor:
    CREATE OR REPLACE PACKAGE WASTYPES
    is
    TYPE GenericCurType IS REF CURSOR;
    END WASTypes;
    In a function I'm opening the cursor via
    'Open cursorVariable for sqlStatement';
    Then this cursor variable is passed to the java method and the
    error ORA-03113 is shown.
    I tried to solve the problem by changing the type of the
    parameter to oracle.sql.REF without success.
    Does anybody know what wents wrong?
    Thanks in advance.
    Jan

    Hi,
    I've written a small Java class with a static method and
    imported that into Oracle 8i. The method expects a
    java.sql.ResultSet object as parameter. According to the
    documentation of Oracle, a REF CURSOR (cursor variable) maps to
    java.sql.ResultSet in JDBC.
    The definition of the Java Stored Procedure was accepted without
    problems:
    CREATE OR REPLACE PROCEDURE RESULTSETPASSINGTESTPROC (row
    WASTypes.GenericCurType)
    as language java
    name 'sqlj.ResultSetPassingTest.testResultSetPassing
    (java.sql.ResultSet)';
    WASTypes is a package containing the definition of the generic
    cursor:
    CREATE OR REPLACE PACKAGE WASTYPES
    is
    TYPE GenericCurType IS REF CURSOR;
    END WASTypes;
    In a function I'm opening the cursor via
    'Open cursorVariable for sqlStatement';
    Then this cursor variable is passed to the java method and the
    error ORA-03113 is shown.
    I tried to solve the problem by changing the type of the
    parameter to oracle.sql.REF without success.
    Does anybody know what wents wrong?
    Thanks in advance.
    Jan

  • Ref Cursors in a stored Procedure

    Can some help me with an answer to the below question.
    How many ref cursors can be declared in a stored procedure in oracle?
    Thanks

    user533016 wrote:
    You are right. Keeping so many cursors open is not good at all. But i was doing this to see where it breaks and is there something that definitely controls the number of refcursors in allowed a PL/SQL block.As Karthick already mentioned you have the OPEN_CURSORS parameter which defines how many open cursors you may have in any one session.
    However, this doesn't just apply to Ref Cursors. If you open explicitly defined cursors then this will also count towards that, as well as issuing select statements as they are implicit cursors... e.g.
    declare
      cursor c1 is
        select * from emp;
      cursor c2 is
        select * from dept;
      v_c1 c1%ROWTYPE;
      v_c2 c2%ROWTYPE;
      v_cnt number;
    begin
      open c1; -- now we have 1 open cursors
      loop
        fetch c1 into v_c1;
        exit when c1%notfound;
        open c2;  -- now we have 2 open cursors
        loop
          fetch c2 into v_c2;
          exit when c2%notfound;
          select count(*)  -- this counts as opening cursor number 3.
          into v_cnt
          from payroll;
          -- after the select statement the implicit cursor is automatically closed, so now we have 2 open again
        end loop;
        close c2; -- after this we just have 1 more open
      end loop;
      close c1; -- after this we have no open cursors
    end;

  • How do I get the returned cursor from a stored procedure to an asp.

    Sorry if this topic has been answered before but I am new to Oracle and ASP. I have been asked to create some stored procedures and access the results from the ASP. I will be passing one variable in and could be getting upto 200 rows returned.
    I have no trouble with the stored procedure but have no clue how to retrieve the data returned by it.

    Assuming that the stored procedure has a single argument, an OUT cursor, you should be able to do
    SQLExecDirect
    {call <stored_proc>() }
    SQLFetch
    SQLGetData
    We'll handle all the 'magic' underneath.
    Justin Cave
    ODBC Development

  • REF CURSOR RETURNED FROM STORED PROCEDURE OPENED WITH CURRENT_USER PRIVILEGES

    Hi.
    I was wondering if anyone knows when this bug will be fixed. The bug# is 899567 off of metalink.
    I am running into this problem as well, and we do not want to use OCI/SQLNet as the fix. We have an application with secure data concerns and only want to give access to stored procedures to an application user.
    Thanks,
    Brad

    I'm using version 8.1.6.0.0 on a W2K server.
    PS: a strange behaveour
    if i try to insert a row using the following anonymous pl/sql block
    begin
    insert into objects select 2, 'B', ref(c) from meta.classes c where id =1;
    end;
    i get the following error msg
    ERROR at line 1:
    ORA-06552: PL/SQL: Compilation unit analysis terminated
    ORA-06553: PLS-302: component 'OBJ_T' must be declared
    but if i use only the sql command from the sql plus prompt
    insert into objects select 2, 'B', ref(c) from meta.classes c where id =1;
    the row is inserted.
    OBJ_T is the object type(id number, label varchar2, class ref class_t),
    OBJECTS is a table of obj_t,
    CLASS_T is an object type(id number, label varchar2)
    CLASSES is a table of CLASS_T.
    null

  • How to return integer used wit DMBS_SQL as ref cursor ?

    I am trying to return a ref cursor form a procedure to be used by xsql to output hierarchical XML.
    I created the query using the DBMS_SQL package, did an OPEN_CURSOR and then PARSE.
    Can I, and if so how, return the integer from the PARSE as a ref cursor out of my procedure ? According to the docs the integer in the PARSE is the ID number for a cursor.
    thanks,
    Reinier

    I suspect that you are a little confused. I doubt that what you are asking for is what you really need. I believe you want the contents of a ref cursor, not an integer that is the cursor id. Since you are using Oracle 8i, as mentioned in your other post, you don't need DBMS_SQL; You just need to open a ref cursor dynmacially. Please see my response to your other post:
    Re: Error while compiling form in AS 10g  deployed on Linux

  • Problem to call stored procedure with several IN pars and single REF Cursor

    Hi,
    Oracle 9.2.0.1
    Ole DB Provider I've got with ODP 9.2.0.4
    First I try to call packaged procedure with single
    REF CURSOR - it works fine(PROCEDURE getDep(dep OUT DEPART.refcur) IS ...).
    When I try to call procedure with additional IN parameter, I get an error ORA-01008: not all variables bound.
    Packaged procedure: PROCEDURE getDep(dep OUT DEPART.refcur, i1 IN number) IS .... and so on.
    Try to call from C#:
    cmd.CommandText = "{call depart.getDep(?)}";
    OleDbParameter par0 = cmd.CreateParameter();
    par0.Value = some value;
    par0.DbType = DbType.Int16;
    par0.OleDbType = OleDbType.Integer;
    par0.Direction = ParameterDirection.Input;
    OleDbDataAdapter da = new OleDbDataAdapter(cmd.CommandText,con);
    DataSet ds = new DataSet();
    da.Fill(ds);
    Connection string:
    "Provider=OraOLEDB.Oracle;User Id=scott;Password=tiger;Data Source=ora92;OLEDB.NET=true;PLSQLRSet=true"
    Please, HELP !
    Thanks in advance,
    Vyacheslav

    Hi,
    Are you using OLEDB.NET driver (System.Data.Oledb) or ODP.NET driver (Oracle.DataAccess)?
    If you are using ODP.NET, remember that you need to bind the refcursor output variable also (besides the numbder)
    Arnold

  • Ref cursors don't work in declared procedures?

    It appears that ref cursors in declared procedures don't work.
    For example, the following code runs with no errors, but returns nothing from the ref cursor -
    s = s & "DECLARE" & vbLf
    s = s & " TYPE OutCurType IS REF CURSOR;" & vbLf
    s = s & "PROCEDURE xxxProc(p5 in out OutCurType )" & vbLf
    s = s & " AS" & vbLf
    s = s & "BEGIN" & vbLf
    s = s & " OPEN p5 FOR SELECT * FROM table;" & vbLf
    s = s & "END xxxProc;" & vbLf
    s = s & "BEGIN" & vbLf
    s = s & " xxxProc( :p5 );" & vbLf
    s = s & "END;" & vbLf
    oCmd.CommandText = s
    oCmd.CommandType = CommandType.Text
    oParam6.ParameterName = "p5"
    oParam6.OracleDbType = Oracle.DataAccess.Client.OracleDbType.RefCursor
    oParam6.Direction = ParameterDirection.Output
    oParam6.Value = DBNull.Value
    oCmd.Parameters.Add(oParam6)
    oCmd.ExecuteNonQuery()
    oDR = CType(oCmd.Parameters("p5").Value, Oracle.DataAccess.Types.OracleRefCursor).GetDataReader
    While oDR.Read
    Stop
    End While
    However, a previously created procedure executes fine, in the above code -
    s = "BEGIN" & vbLf
    s = s & " xxxPkg.xxxProc( :p5 );" & vbLf
    s = s & "END;" & vbLf
    Is there a way to get ref cursors to work in declared procedures? Thanks...

    Fixed the grid cell display and popup editor for Ref Cursors.
    -Raghu

  • Hyperion get ref cursor data

    Hi,
    Is there any way to execute stored procedure via hyperion using ODBC and get back ref cursor data.
    I tried to call a stored procedure that have a ref cursor out parameter but it gives me error.
    My stored procedure code is below.
    wrong number or types of arguments to in call to 'HYP_CURSOR'
    create or replace package hyp_ref_cusrsor is
    type t_cusror is ref cursor;
    end;
    create or replace procedure hyp_cursor(ret1 out hyp_ref_cusrsor.t_cusror) is
    begin
    open  ret1 for select * from hyp_tmp1 m;
    end;
    Hyperion version is 9.3.1
    Oracle version is 10.0.2
    Regards

    George wrote:
    Is there a limit to the volume of data a ref cursor can return via an Oracle Database Procedure call? No.
    {thread:id=886365}
    Re: OPEN cursor for large query
    A ref cursor is a pointer to a compiled SQL statement, it has no rows so there is no limit to the number of rows that you can use it to fetch, just like there is no limit to the number of rows a select can return.
    I am using a ref cursor to return data and testing using toad, it hangs the session. My Business Object report also hangs because of the large data volume 750,000 rows returned via a ref cursor. This is very confusing, it it hangs how do you know it returns 750,000 rows?

  • Is there a different way to open a cursor for a ref cursor procedure?

    hello everybody
    i have two cursors, cur_a and cur_b, declared somewhere else in my application.
    These two cursors have the same fields, in the same order, and i have to treat both in the same way. So i wrote a routine that gets as input a ref cursor based on the cur_a rowtype, and i am trying to use this routine for both.
    The problem is that i am not able to open outside the routine the cursor in a different way than usual...
    the common method is :
    declare curs ref cursor ...
    begin
    open curs for (select *...)
    end;
    instead i would like to obtain something different
    declare curs ref cursor ...
    begin
    open curs for cur_a
    end;

    hi
    thanks for answering
    i wanted just to give a better idea, anyway you were near to get it.
    the only difference is that the two cursors are not written in dynamic sql, just like strings, but are real cursors.
    anyway, this is the version of the package i need, but i am not able to compile
    (your original code is commented and immediately below there is my code)
    CREATE OR REPLACE PACKAGE BODY mytest
    IS
    --cur_a VARCHAR2(200) := 'SELECT dummy FROM DUAL';
    CURSOR cur_a
    IS
    SELECT dummy
    FROM DUAL;
    --cur_b VARCHAR2(200) := 'SELECT ''fred'' FROM DUAL';
    CURSOR cur_b
    IS
    SELECT 'fred' fred
    FROM DUAL;
    TYPE t_cur_a IS REF CURSOR
    RETURN cur_a%ROWTYPE
    --PROCEDURE routine_a_b (p_cur SYS_REFCURSOR) IS
    PROCEDURE routine_a_b (p_cur t_cur_a)
    IS
    v_x VARCHAR2 (10);
    BEGIN
    LOOP
    FETCH p_cur
    INTO v_x;
    EXIT WHEN p_cur%NOTFOUND;
    DBMS_OUTPUT.put_line (v_x);
    END LOOP;
    END;
    PROCEDURE doit
    IS
    --v_curs SYS_REFCURSOR;
    v_curs t_cur_a;
    BEGIN
    NULL;
    -- open v_curs FOR cur_a;
    OPEN v_curs FOR cur_a;
    routine_a_b (v_curs);
    CLOSE v_curs;
    -- open v_curs FOR cur_b;
    -- routine_a_b(v_curs);
    -- close v_curs;
    END;
    END;
    the error is:
    cursor 'V_CURS' cannot be used in dynamic SQL OPEN statement
    i did read that if use weak ref cursor, it could work, so i declare the ref cursor type in this way:
    TYPE t_cur_a IS REF CURSOR;
    instead than
    TYPE t_cur_a IS REF CURSOR
    RETURN cur_a%ROWTYPE
    what i get is another error (in the open cursor command)
    PLS-00382: expression is of wrong type....
    but if i replace
    OPEN v_curs FOR cur_a;
    with
    OPEN v_curs for select dummy from dual;
    it works... but i already knew it.. :-)
    anyway, i used a work around to resolve it, so it's just philosophy

  • OUT parameter of type REF CURSOR

    DB: Oracle Database 10g Release 10.2.0.3.0 - Production
    OS: Windows xp
    I have got these two types:
    TYPE myrecord IS RECORD
    (column1           tab1.col1%TYPE,
    column2         tab1.col2%TYPE
    TYPE my_ref_cur IS REF CURSOR RETURN myrecord;Then I have this procedure:
    PROCEDURE proc1 (pid          IN       NUMBER, pout1      OUT my_ref_cur);How can I call the procedure from a pl/sql block and fetch from the cursor variable?
    I tried this, but it does not work for me:
    DECLARE
      lid NUMBER := 748;
      lcur1 my_ref_cur
    begin
      proc1 (lid, lcur1);
    end;I receive the error Wrong number or types of arguments in call to 'proc1'
    How it must be called?
    Thanks

    seems to work
    SQL> create table tab1
      2  (col1 number
      3  ,col2 number
      4  );
    Table created.
    SQL> insert into tab1 values (1,1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> create or replace package pack
      2  is
      3     TYPE myrecord IS RECORD
      4     (column1           tab1.col1%TYPE,
      5      column2         tab1.col2%TYPE
      6     );
      7     TYPE my_ref_cur IS REF CURSOR RETURN myrecord;
      8     procedure proc1 (pid          IN       number
      9                    , pout1      OUT my_ref_cur);
    10  end pack;
    11  /
    Package created.
    SQL>
    SQL> show error
    No errors.
    SQL>
    SQL> create or replace
      2  package body pack
      3  is
      4     procedure proc1 (pid          IN       number
      5                    , pout1      OUT my_ref_cur
      6                    )
      7     is
      8     begin
      9        open pout1
    10        for select col1
    11                 , col2
    12        from tab1;
    13     end proc1;
    14  end pack;
    15  /
    Package body created.
    SQL> show error
    No errors.
    SQL>
    SQL> DECLARE
      2    lid NUMBER := 748;
      3    lcur1 pack.my_ref_cur;
      4    r tab1%rowtype;
      5  begin
      6    pack.proc1 (lid, lcur1);
      7    fetch lcur1 into r;
      8    dbms_output.put_line (r.col1||' - '||r.col2);
      9    close lcur1;
    10  end;
    11  /
    1 - 1
    PL/SQL procedure successfully completed.

  • Stored procedure call with REF CURSOR from JDBC

    How can I call a SP with a REF CURSOR OUT parameter from JDBC?

    This is a breeze.
    CallableStatement oraCall = oraConn.prepareCall("BEGIN PKG_SOMETHING.RETURNS_A_SP(?);END;");
    oraCall.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CURSOR);
    oraCall.execute();
    ResultSet rsServList = (ResultSet) oraCall.getObject(1);
    ... use ResultSet ...
    rsServList.close();
    oraCall.close();
    slag

Maybe you are looking for