Return Cursor as OUT Parameter

I have one Implicit Cursor which will store the table Data.May I have any Chance to send Implicit Cursor as OUT parameter?.

1) cursors (implicit or explicit) do NOT STORE table data. tables store table data.
2) why does implicit vs explicit matter to you? just write the code in the way that works
3) to return a cursor, use a refcursor
create procedure y ( rc in out sys_refcursor ) as
begin
open rc for select * from dual;
end;
SQL> var rc refcursor
SQL> exec y ( :rc )
PL/SQL procedure successfully completed.
SQL> print rc
D
X
1 row selected.

Similar Messages

  • Stored procedure with cursor as out parameter

    Can any one help me by showing how to write a procedure with cursor as out parameter and caputuring it in java using jdbc.
    Thanks in advance,
    shravan bharadwaj

    I know that in the SQLJ distribution (which is also downloadable) there is an example in the demo directory called RefCursDemo that shows the SQL code and how to call it - albeit from SQLJ and not JDBC. There may also be a demo in the JDBC distribution, though I am not sure about that.

  • Is it possible to return a cursor as a HANA Stored Procedure OUT parameter?

    Hi,
    I have a use case where I need to return a record set from a HANA Stored Procedure to the caller based on a couple of input parameters to the procedure. However, the record set needs to be dynamic and may have different columns based on the input parameters.
    I could achieve this by creating hdbstructures or using table types as OUT parameters. However, is it possible to return a cursor holding the result set of a SELECT query as an OUT parameter for a HANA stored procedure?
    (I am looking for something similar to Oracle's SYS_REFCURSOR)
    Best Regards,
    Abhik

    Did you try using EXECUTE IMMEDIATE
    Have a look on this:
    SAP HANA: Handling Dynamic Select Column List and Multiple values in input parameter
    Regards,
    Krishna Tangudu

  • Performance problem with sproc and out parameter ref cursor

    Hi
    I have sproc with Ref Cursor as an OUT parameter.
    It is extremely slow looping over the ResultSet (does it record by record in the fetch).
    so I have added setPrefetchRowCount(100) and setPrefetchMemorySize(6000)
    pseudo code below:
    string sqlSmt = "BEGIN get_tick_data( :v1 , :v2); END;";
    Statement* s = connection->createStatement(sqlStmt);
    s->setString(1, i1);
    // cursor ( f1 , f2, f3 , f4 , i1 ) f for float type and i for interger value.
    // 5 columns as part of cursor with 4 columns are having float value and
    // 1 column is having int value assuming 40 bytes for one rec.
    s->setPrefetchRowCount (100);
    s->PrefetchMemorySize(6000);
    s->registerOutParam(2,OCCICURSOR);
    s->execute();
    ResultSet* rs = s->getCursor(2);
    while (rs->next()) {
    // do, and do v slowly!
    }

    Hi,
    I have the same problem. It seems, when retrieving cursor, that "setPrefetchRowCount" is not taking into account by OCCI. If you have a SQL statement like "SELECT STR1, STR2, STR3 FROM TABLE1" that works fine but if your SQL statement is a call to a stored procedure returning a cursor each row fetching need a roudtrip.
    To avoid this problem you need to use the method "setDataBuffer" from the object "ResultSet" for each column of your cursor. It's easy to use with INT type and STRING type, a lit bit more complex with DATE type. But until now, I'm not able to do the same thing with REF type.
    Below a sample with STRING TYPE (It's assuming that the cursor return only one column of STRING type):
    try
      l_Statement = m_Connection->createStatement("BEGIN :1 := PACKAGE1.GetCursor1(:2); END;");
      l_Statement->registerOutParam(1, oracle::occi::OCCINUMBER, sizeof(l_CodeErreur));
      l_Statement->registerOutParam(2, oracle::occi::OCCICURSOR);
      l_Statement->executeQuery();
      l_CodeErreur = l_Statement->getNumber(1);
      if ((int) l_CodeErreur     == 0)
        char                         l_ArrayName[5][256];
        ub2                          l_ArrayNameSize[5];
        l_ResultSet  = l_Statement->getCursor(2);
        l_ResultSet->setDataBuffer(1, l_ArrayName,   OCCI_SQLT_STR, sizeof(l_ArrayName[0]),   l_ArrayNameSize,   NULL, NULL);
        while (l_ResultSet->next(5))
          for (int i = 0; i < l_ResultSet->getNumArrayRows(); i++)
            l_Name = CString(l_ArrayName);
    l_Statement->closeResultSet(l_ResultSet);
    m_Connection->terminateStatement(l_Statement);
    catch (SQLException &p_SQLException)
    I hope that sample help you.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Returning result set from procedure out parameter, display with anon block

    I'm trying to do something pretty simple (I think it should be simple at least). I want to use a pl/sql procedure to return a result set in an OUT parameter. If I run this code by itself (in the given anonymous block at the end, without trying to display any results), toad says that the PL/SQL procedure successfully completed.
    How can I display the results from this procedure? I am assuming that the result set should be stored in the O_RETURN_REDEEM_DTL, but how can I get anything out of it?
    I have this package with the following procedure:
    /* FUNCTION - REDEEM_DTL_READ                          */
         PROCEDURE REDEEM_DTL_READ(
              ZL_DIVN_NBR_IN     IN     REDEEM_DTL.ZL_DIVN_NBR%TYPE,
              GREG_DATE_IN     IN     REDEEM_DTL.GREG_DATE%TYPE,
              ZL_STORE_NBR_IN     IN     REDEEM_DTL.ZL_STORE_NBR%TYPE,
              REGISTER_NBR_IN     IN     REDEEM_DTL.REGISTER_NBR%TYPE,
              TRANS_NBR_IN     IN     REDEEM_DTL.TRANS_NBR%TYPE,
              O_RETURN_REDEEM_DTL OUT REDEEM_DTL_TYPE,
              o_rtrn_cd       OUT NUMBER,
              o_err_cd        OUT NUMBER,
              o_err_msg       OUT VARCHAR2
         IS
         BEGIN
              o_rtrn_cd := 0;
              o_err_msg := ' ';
              o_err_cd := 0;
              --OPEN REDEEM_DTL_READ_CUR(ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN, REGISTER_NBR_IN, TRANS_NBR_IN);
              OPEN O_RETURN_REDEEM_DTL FOR SELECT * FROM REDEEM_DTL;
    --           LOOP
    --                FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
    --                EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
    --           END LOOP;
    --           CLOSE REDEEM_DTL_READ_CUR;
         EXCEPTION
          WHEN OTHERS
          THEN
               o_rtrn_cd := 7;
                 o_err_msg := SUBSTR (SQLERRM, 1, 100);
                 o_err_cd  := SQLCODE;
         END REDEEM_DTL_READ;and call it in an anonymous block with:
    DECLARE
      ZL_DIVN_NBR_IN NUMBER;
      GREG_DATE_IN DATE;
      ZL_STORE_NBR_IN NUMBER;
      REGISTER_NBR_IN NUMBER;
      TRANS_NBR_IN NUMBER;
      O_RETURN_REDEEM_DTL PSAPP.CY_SALESPOSTING.REDEEM_DTL_TYPE;
      O_RETURN_REDEEM_DTL_OUT PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ_CUR%rowtype;
      O_RTRN_CD NUMBER;
      O_ERR_CD NUMBER;
      O_ERR_MSG VARCHAR2(200);
    BEGIN
      ZL_DIVN_NBR_IN := 71;
      GREG_DATE_IN := TO_DATE('07/21/2008', 'MM/DD/YYYY');
      ZL_STORE_NBR_IN := 39;
      REGISTER_NBR_IN := 1;
      TRANS_NBR_IN := 129;
      -- O_RETURN_REDEEM_DTL := NULL;  Modify the code to initialize this parameter
      O_RTRN_CD := NULL;
      O_ERR_CD := NULL;
      O_ERR_MSG := NULL;
      PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ ( ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
    REGISTER_NBR_IN, TRANS_NBR_IN, O_RETURN_REDEEM_DTL, O_RTRN_CD, O_ERR_CD, O_ERR_MSG );
      FOR item IN O_RETURN_REDEEM_DTL
      LOOP
        DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || item.ZL_DIVN_NBR);
      END LOOP;
    END; And end up with an error:
    ORA-06550: line 25, column 15:
    PLS-00221: 'O_RETURN_REDEEM_DTL' is not a procedure or is undefined
    ORA-06550: line 25, column 3:
    PL/SQL: Statement ignoredMessage was edited by:
    user607908

    Aha, I knew I forgot something!
    I actually had it defined as a REF CURSOR in PSAPP.CY_SALESPOSTING package spec:
    TYPE REDEEM_DTL_TYPE IS REF CURSOR;since I wasn't sure what to make it.
    Cursor used in procedure:
    CURSOR REDEEM_DTL_READ_CUR (
      zl_divn_nbr_in IN NUMBER,
      greg_date_in IN DATE,
      zl_store_nbr_in IN NUMBER,
      register_nbr_in IN NUMBER,
      trans_nbr_in IN NUMBER)
    IS
    SELECT ZL_DIVN_NBR, GREG_DATE, ZL_STORE_NBR, REGISTER_NBR, TRANS_NBR, PAYMENT_TYP_NBR
    FROM REDEEM_DTL
    WHERE ZL_DIVN_NBR = zl_divn_nbr_in AND GREG_DATE = greg_date_in AND
       ZL_STORE_NBR = zl_store_nbr_in AND REGISTER_NBR = register_nbr_in AND
       TRANS_NBR = trans_nbr_in;Updated code:
    /* PROCEDURE - REDEEM_DTL_READ                          */
         PROCEDURE REDEEM_DTL_READ(
              ZL_DIVN_NBR_IN     IN     REDEEM_DTL.ZL_DIVN_NBR%TYPE,
              GREG_DATE_IN     IN     REDEEM_DTL.GREG_DATE%TYPE,
              ZL_STORE_NBR_IN     IN     REDEEM_DTL.ZL_STORE_NBR%TYPE,
              REGISTER_NBR_IN     IN     REDEEM_DTL.REGISTER_NBR%TYPE,
              TRANS_NBR_IN     IN     REDEEM_DTL.TRANS_NBR%TYPE,
              O_RETURN_REDEEM_DTL OUT REDEEM_DTL_TYPE,
              o_rtrn_cd       OUT NUMBER,
              o_err_cd        OUT NUMBER,
              o_err_msg       OUT VARCHAR2
         IS
         BEGIN
              o_rtrn_cd := 0;
              o_err_msg := ' ';
              o_err_cd := 0;
              OPEN REDEEM_DTL_READ_CUR(ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
                   REGISTER_NBR_IN, TRANS_NBR_IN);
              --OPEN O_RETURN_REDEEM_DTL FOR SELECT * FROM REDEEM_DTL;
              LOOP
                  FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
                   EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
                   DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || O_RETURN_REDEEM_DTL.ZL_DIVN_NBR);
                END LOOP;
               CLOSE REDEEM_DTL_READ_CUR;
    --           LOOP
    --                FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
    --                EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
    --           END LOOP;
    --           CLOSE REDEEM_DTL_READ_CUR;
         EXCEPTION
          WHEN OTHERS
          THEN
               o_rtrn_cd := 7;
                 o_err_msg := SUBSTR (SQLERRM, 1, 100);
                 o_err_cd  := SQLCODE;
         END REDEEM_DTL_READ;the updated anon block:
    DECLARE
      ZL_DIVN_NBR_IN NUMBER;
      GREG_DATE_IN DATE;
      ZL_STORE_NBR_IN NUMBER;
      REGISTER_NBR_IN NUMBER;
      TRANS_NBR_IN NUMBER;
      O_RETURN_REDEEM_DTL PSAPP.CY_SALESPOSTING.REDEEM_DTL_TYPE;
      O_RTRN_CD NUMBER;
      O_ERR_CD NUMBER;
      O_ERR_MSG VARCHAR2(200);
    BEGIN
      ZL_DIVN_NBR_IN := 71;
      GREG_DATE_IN := TO_DATE('07/21/2008', 'MM/DD/YYYY');
      ZL_STORE_NBR_IN := 39;
      REGISTER_NBR_IN := 1;
      TRANS_NBR_IN := 129;
      -- O_RETURN_REDEEM_DTL := NULL;  Modify the code to initialize this parameter
      O_RTRN_CD := NULL;
      O_ERR_CD := NULL;
      O_ERR_MSG := NULL;
      PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ ( ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
         REGISTER_NBR_IN, TRANS_NBR_IN, O_RETURN_REDEEM_DTL, O_RTRN_CD, O_ERR_CD, O_ERR_MSG );
      FOR item IN 1..O_RETURN_REDEEM_DTL.COUNT
      LOOP
        DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || O_RETURN_REDEEM_DTL(item).ZL_DIVN_NBR);
      END LOOP;
    END;and the new error:
    ORA-06550: line 25, column 38:
    PLS-00487: Invalid reference to variable 'O_RETURN_REDEEM_DTL'
    ORA-06550: line 25, column 3:
    PL/SQL: Statement ignoredAlso, it would be nice if the forums would put a box around code so that it would be easy to
    distinguish between what is supposed to be code and what should be regular text...
    Message was edited by:
    user607908

  • How to return more than one record through OUT parameter in procedure

    Hi,
    I want to create a procedure which accepts one input and returns more than one record as output.
    example:
    Input = DeptNo
    Output= Empno,ename,sal,comm,job
    Scenario:
    There can be more than one employee in department we pass as the IN parameter. OUT parameter has to return all the records of the corresponding employee details in that department.
    Thanks in advance for your help
    Regards,
    K.Vijay

    -- I think you can try something like this using ref cursor:
    -- create a package for the type ref cursor and execute
    CREATE OR REPLACE PACKAGE PACK_REFCURSOR_FOR_TABLES AS
         TYPE DATA_TableRows IS REF CURSOR;
    END;
    -- after executing the package above, create your procedure:
    CREATE OR REPLACE PROCEDURE GET_EMP (
         IN_nDeptNo IN number,
         OUT_Emp OUT PACK_REFCURSOR_FOR_TABLES.DATA_TableRows)
    IS
    BEGIN
    -- leave query open (implicit) as this will return data
         OPEN OUT_Emp FOR
         SELECT *
         FROM tblEmp
         WHERE DeptNo = IN_nDeptNo;
    END;
    --execute the procedure and you're done                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ResultSet of a cursor as an out parameter

    How can you return a cursor or a resultSet as an OUT parameter? - Any info will be greatly appreciated. A code ex will be great
    vj

    Assuming you mean as an output parameter of pl/sql procedure being called from pl/sql...
    declare
      type refcur_type is ref cursor;
      type tab_user_tables_type is table of user_tables%rowtype index by binary_integer;
      refcur_user_tables refcur_type;
      tab_user_tables tab_user_tables_type;
      row_user_tables user_tables%rowtype;
      procedure get (
        out_refcur_user_tables out refcur_type,
        out_tab_user_tables out tab_user_tables_type) is
      begin
        for row_user_tables in (select * from user_tables) loop
          out_tab_user_tables(nvl(out_tab_user_tables.count, 0) + 1) := row_user_tables;
        end loop;
        open out_refcur_user_tables for select * from user_tables;
      end get;
    begin
      get(refcur_user_tables, tab_user_tables);
      dbms_output.put_line('from table ...');
      for i in 1 .. tab_user_tables.count loop
        dbms_output.put_line(tab_user_tables(i).table_name);
      end loop;
      dbms_output.put_line('from reference cursor ...');
      loop
        fetch refcur_user_tables into row_user_tables;
        exit when refcur_user_tables%notfound;
        dbms_output.put_line(row_user_tables.table_name);
      end loop;
    end;

  • Getting resultset from out parameter ref cursor

    hi,
    i have written one procedure which return one refcursor as out parameter.
    when i am calling that proceduer how can i retrive that resultsets in my current program.
    ex
    DECLARE
    type A is ref cursor;
    B A;
    x NUMBER :=0;
    BEGIN
    APPSEARCH(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,B);
    FOR i in b
    loop
    x:= x+1;
    end loop;
    DBMS_OUTPUT.PUT_LINE('ANS '||x);
    END;
    but it is giving error
    please advice
    thanks
    siva

    Thanks alessandro,
    SQL> DECLARE
    2 type A is ref cursor;
    B A;
    3 4 C b%rowtype;
    5 d NUMBER;
    6 BEGIN
    7 APPSEARCH(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,B);
    8 loop
    9 fetch b into c;
    10 exit when b%notfound;
    11 DBMS_OUTPUT.PUT_LINE('ANS '||c%rowcount);
    12 end loop;
    13 close b;
    14 END;
    15 /
    C b%rowtype;
    ERROR at line 4:
    ORA-06550: line 4, column 4:
    PLS-00320: the declaration of the type of this expression is incomplete or
    malformed
    ORA-06550: line 4, column 4:
    PL/SQL: Item ignored
    ORA-06550: line 9, column 17:
    PLS-00320: the declaration of the type of this expression is incomplete or
    malformed
    ORA-06550: line 9, column 4:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 11, column 35:
    PLS-00320: the declaration of the type of this expression is incomplete or
    malformed
    ORA-06550: line 11, column 6:
    PL/SQL: Statement ignored
    i dont know how to transfer the resultset from the procedure refcursor out parameter to my local cursor variable please help

  • Cursor bound to out parameter with Connection Pool

    Is it possible to retrieve a cursor bound to an out parameter when using the thin
    driver to establish the connection pool to the database? I am currently using
    the JDriver to connect create the pool and the pool driver to connect from the
    app to the connection pool. We'd like to avoid using the Oracle client if possible.
    Currently I register the out parameter as java.sql.Types.OTHER, then call getResultSet(1)
    on the weblogic.jdbc.pool.CallableStatement object. But it breaks when I change
    the connection pool to use the thin driver. The error is at the bottom of this
    post.
    I think I could possibly get the current pool driver to work if can find some
    documentation on these two methods:
    void registerOutParameter(int i, int j, int k, int l)
    void registerOutParameter(int i, int sqlType, java.lang.String typeName)
    I have no idea what to put in for the ints in the first method or for sqlType
    or typeName. Can anyone point me to where I can find this documentation?
    E-docs mentions this class: weblogic.jdbc.vendor.oracle.OracleCallableStatement.
    (http://edocs.bea.com/wls/docs61/jdbc/thirdparty.html#1023867). Should I consider
    this? If so where is it?
    Thanks a lot,
    Matt Savino
    <<< error when using thin driver >>>
    preparing callable stmt
    callable stmt prepared, java.sql.Types.OTHER = 1111
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:225)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:350)
    at weblogic.jdbc.pool.Statement.registerOutParameter(Statement.java:617)
    at jsp_servlet._reportmanager.__thin_outputresultset._jspService(__thin_outputresultset.java:145)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:263)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

    Thanks Joe, your answer pointed me in the right direction. Just in case anyone
    wants to know, the solution took two changes:
    CHANGE
    cStat.registerOutParameter(1, java.sql.Types.OTHER);
    TO
    cStat.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
    (cStat is an instance of weblogic.jdbc.pool.CallableStatement)
    AND
    rs = cStat.getResultSet(1);
    TO
    rs = cStat.getCursor(1);
    Thanks again,
    Matt
    Joseph Weinstein <[email protected]> wrote:
    Hi Matt.
    Look at the Oracle thin driver documentation to determine what type you
    should define in the registerOutParameter call. We use 'OTHER', but
    their driver may use something else for CURSOR output parameters.
    joe
    Matt Savino wrote:
    Is it possible to retrieve a cursor bound to an out parameter whenusing the thin
    driver to establish the connection pool to the database? I am currentlyusing
    the JDriver to connect create the pool and the pool driver to connectfrom the
    app to the connection pool. We'd like to avoid using the Oracle clientif possible.
    Currently I register the out parameter as java.sql.Types.OTHER, thencall getResultSet(1)
    on the weblogic.jdbc.pool.CallableStatement object. But it breaks whenI change
    the connection pool to use the thin driver. The error is at the bottomof this
    post.
    I think I could possibly get the current pool driver to work if canfind some
    documentation on these two methods:
    void registerOutParameter(int i, int j, int k, int l)
    void registerOutParameter(int i, int sqlType, java.lang.String typeName)
    I have no idea what to put in for the ints in the first method or forsqlType
    or typeName. Can anyone point me to where I can find this documentation?
    E-docs mentions this class: weblogic.jdbc.vendor.oracle.OracleCallableStatement.
    (http://edocs.bea.com/wls/docs61/jdbc/thirdparty.html#1023867). Should
    I consider
    this? If so where is it?
    Thanks a lot,
    Matt Savino
    <<< error when using thin driver >>>
    preparing callable stmt
    callable stmt prepared, java.sql.Types.OTHER = 1111
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:225)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:350)
    at weblogic.jdbc.pool.Statement.registerOutParameter(Statement.java:617)
    at jsp_servlet._reportmanager.__thin_outputresultset._jspService(__thin_outputresultset.java:145)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:263)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced
    positions
    for people who want to work with Java, XML, SOAP and E-Commerce infrastructure
    products.
    We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose
    CA.
    Send resumes to [email protected]

  • Returning Clause out parameter not working

    I have Oracle 11g (I think?) and VS2010.
    I am using an insert statement with the returning clause to return an identity value that is created by a Sequence/Trigger. The problem I am having is that it is not updating the out parameter in C#. Here's some sample code. I have tested the insert statement in SQL Developer and it works. The C# statement does do the insert, but the out parameter remains null. I have tried ParameterDirection as ReturnValue, InputOutput, and Output. None of those worked. The output value remains null no matter what I try to do. I even lifted this example (Oracle Sequences), ran it, and it also errored and is not returning out parameters. (Error Msg: Unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' to type 'System.IConvertible'.Couldn't store <null> in ID Column.  Expected type is Int32.).
    I have searched and searched the web over and I cannot figure out why this does not work. Any help would be most appreciated!!
    MyTable
    MyTable_ID  Number (38)
    Note            Varchar2 (500 byte)
    =================================================
                    try
                        if (insertCmd.Connection.State == ConnectionState.Closed)
                            insertCmd.Connection.Open();
                        int recs = insertCmd.ExecuteNonQuery();
                        this.Id = Convert.ToInt32(insertCmd.Parameters[":Id"].Value);
                    catch (Exception err) {  }
                    finally {  insertCmd.Connection.Close(); }
    private OracleCommand insertCmd
                get
                    OracleCommand insCmd = Context.DataBaseConnection.CreateCommand();
                    insCmd.CommandText = string.Format(
                        @"Insert into MyTable (Note)
                          Values (:Note)
                          Returning MyTable_ID into :Id");
                    insCmd.Parameters.Clear();
                    OracleParameter noteParam = new OracleParameter(":Note", OracleDbType.Varchar2, Note, ParameterDirection.Input);
                    OracleParameter idParam = new OracleParameter(":Id", OracleDbType.Int32, 38, "Calibration_Session_Id");
                    idParam.Direction = ParameterDirection.Output;
                    insCmd.Parameters.Add(idParam);
                    insCmd.Parameters.Add(noteParam);
                    insCmd.BindByName = true;
                    return insCmd;

    Okay, I changed my insert command text to this...
    insCmd.CommandText = string.Format(
                        @"Begin
                             Insert into MyTable (Note)
                             Values (:Note)
                             Returning MyTable_ID into :Id;
                             Commit; End;");
    There was no change. Am I doing an explicit transaction wrong?

  • Return Nested Table  Using Out Parameter

    Hi Friends,
    I wrote a function in which i'm using a return type as NUMBER and OUT parameter as TABLE but i'm not able to call the function in PL/SQL because of TABLE ,Can anyone plz tell me how to call the function in PL/sql using TABLE as OUT parameter. The calling function is mentioned below..
    FUNCTION get_label_to_folder (
    i_folder_id IN NUMBER,
    i_label_id IN NUMBER,
    i_new_path IN VARCHAR2,
    i_src_path IN VARCHAR2 DEFAULT NULL,
    --i_output_loc_type   IN       VARCHAR2,
    o_vdoc_table OUT vdocs_table
    RETURN NUMBER;
    I tried to call that function in this manner but it won't work--
    DECLARE
    TYPE vdocs_table IS TABLE OF VARCHAR2 (50);
    vdoc vdocs_array := vdocs_array ();
    vret VARCHAR2 (20);
    BEGIN
    vret :=
    sce_label_util.get_label_to_folder (32272,
    324073,
    '/test-aaaa/a1/',
    NULL,
    vdoc
    FOR i IN vdoc.FIRST .. vdoc.LAST
    LOOP
    DBMS_OUTPUT.put_line (vret || ' ,' || vdoc (i));
    END LOOP;
    END;
    Kindly check it and plz resolve the problem.
    Regards,
    Anand

    It is not the correct approach to do this (passing a collection using an OUT parameter) using a function.
    Does not matter whether you dislike it. It is still wrong.
    It should be a procedure. It should likely define the OUT parameter as being passed by reference and not value in order to decrease the call overheads and increase performance.
    Also note that is it not called a table. The correct terminology is a collection or an associative array. A table is something you get inside the database engine. The structure you define in the PL engine is nothing like a database table and everything like an array.
    PS. And how do you expect us to determine the error? How do you expect us to test anything if we do not know what Oracle version you are using? Please.. FULL details, including Oracle version number and the full Oracle error message!

  • Please help....execute procedure with out parameter -cursor

    HI all plese help me,
    i create a stored procedure like this.hw cani execute the IN out parameter which is a cursor ir..RCT1 is cursor..
    please help...
    CREATE OR REPLACE PROCEDURE ST_GetTravelTypeID
         TravelType IN      VARCHAR2 DEFAULT NULL,
         RCT1 IN OUT      GLOBALPKG.RCT1
    AS
    BEGIN
         OPEN RCT1 FOR
         SELECT
                   TravelTypeCode,
                   TravelTypeDesc
         FROM ST_MS_TravelTypes
         WHERE     TravelType = ST_GetTravelTypeID.TravelType;
    END;
    Message was edited by:
    neethu

    Your reference is invalid:
    WHERE TravelType = ST_GetTravelTypeID.TravelType;
    This should not (cannot) refer to the name of the procedure - but simply to the variable in it. I.e.
    WHERE TravelType = TravelType;
    However, as you can see, the variable name is now the same as the column name.
    One method around this is to use explicit scope reference. E.g.
    SELECT
      t.TravelTypeCode,
      t.TravelTypeDesc
    FROM  ST_MS_TravelTypes t
    WHERE t.TravelType = TravelType;I suggest that you consider this a standard for your PL/SQL programming. Always alias SQL tables in PL/SQL code and use explicit column references.
    Another standard we use is to use underscore characters for columns - camel case is fine for variables in a programming language. This is not really acceptable for column names, as by default Oracle uses uppercase. Thus "TravelType" is valid as variable name, but invalid as a column name - it should be defined/written as "travel_type" or "TRAVEL_TYPE" instead.

  • With JDBC, calling a stored procedure with ARRAY as out parameter

    Hi,
    I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
    With this configuration I can get back a Cursor but not an Array.
    Does it's possible ?
    Thanks for your help !
    Michakl

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Oracle Instant Client and OUT Parameter of custom type in Stored Procedures

    Hi @ all!
    I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
    The stored procedure and assiciated types looks like this:
    TYPE MYVALUE AS OBJECT
          Id      INTEGER,
          value     FLOAT
    TYPE MYVALUELIST AS TABLE OF MYVALUE;
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT MYVALUELIST)
                                           IS
    ...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
    Is it possible to pass a parameter with a custom type from C# in some way?
    I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
    With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
    Any suggestions?
    Thanks in advance!

    Hi Greg!
    Sorry, I misunderstood the forum topic then. =(
    Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
    So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
    OracleCommand cmd = new OracleCommand();
    cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
    OracleDataAdapter odr = new OracleDataAdapter(cmd);
    DataTable result = new DataTable();
    odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT sys_refcursor)
                                           IS
    currentlist MYVALUELIST;
    ... [Adding elements to that list] ...
    OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
    Regards

  • Problem in Mapping RefCursors(in/out parameter) and Collections(in/out)

    Hi,
    Can anyone help to solve the proble listed below as it is affecting the business process
    The API for A is listed below. It takes Oracle Object types as input/output.
    PROCEDURE A(
    p_serviceOrder IN ServiceOrder,
    p_serviceID IN OUT p_sm_type.ServiceID,
    p_serviceOrderID OUT p_sm_type.ServiceOrderID,
    returnStatus OUT CallStatus);
    The ServiceOrder and CallStatus are Oracle Object types.
    The wrapper procedure for this api would be something like the example with pseudo-code below.
    PROCEDURE B(
    p_serviceOrder IN REF CURSOR,
    p_serviceID IN OUT p_sm_type.ServiceID,
    p_serviceOrderID OUT p_sm_type.ServiceOrderID,
    returnStatus OUT REF CURSOR) {
    Map from REF CURSOR p_serviceOrder To Oracle Object for ServiceOrder;
    Map from other data types to local variables;
    Call A(pass the parameters here and get output…);
    Map output CallStatus to its equivalent REF CURSOR variable;
    Return CallStatus (and other OUT parameters if any) as REF CURSORs;
    It will be highly needful for the solution as it is affecting the business flow requirement.
    Regards
    Saugata

    Hi,
    i think you must set the value for this parameter and additional you must
    register this parameter as out parameter.
    I hope it works.

Maybe you are looking for

  • Need assistance - wired PC doesn't "see" AEBS; PC notebook and macbooks do

    Hi everyone. I'm hoping someone will be able to help me with the last step in putting together our home network. I'm certainly not a networking expert by any means, but I've been able to get the wireless aspects of the network (Internet, wireless pri

  • Why my Firefox 10.0 on Windows 7 is slow?

    Hi, I am using Firefox 10.0 on my Windows 7 PC. It is getting slower day by day. There is a delay in typing, and also the reaction time has increased when I click on a button or a Link? What should I do?

  • One month Basic salary

    How do i config in V_512W_B This is for the WT :Payment in lieu Answer will Rewarded

  • Storing data in server's database

    hi i am new in Java ... i am developing a clint-server program with java the clint and the server will run on the same PC (it's a student project) i need to know about the available methods to store data in the server's database .. i've got an idea a

  • Report Sub-Heading output

    Hi All, I have a report sub-heading named "Opening Blance" on my report. I want that when the report output is more than 1 page then "Opening Blance" Heading should be change to "Balance Brought Forward" to 2nd and onward pages but on 1st page it sho