Cursors in Stored Procedures

Hi,
Hope someone can give me few ideas about this:
I have a database table from which I will take each record in a cursor at one time, use that record as IN parameters in a procedure to do modifications on another table and then once it completes it will take the next record from the cursor and execute the procedure again with the new IN parameters from the second record of table1.
Sample Code:
PROCEDURE p_procedure (p_id IN table1.id%TYPE,
p_date IN table1.date%TYPE,
p_code IN table1.code%TYPE) IS
CURSOR c1 IS
SELECT id, date, code
FROM table1
WHERE id = p_id
and date = p_date
and code = p_code;
BEGIN
For crec in c1 LOOP
BEGIN LOOP
UPDATE table2
SET ID = NULL, DATE = NULL, CODE = NULL, PRINT = NULL, TRAN = NULL --updates to columns in table2
WHERE table2.id = p_id
and table2.date = p_date
and table2.code = p_code;
COMMIT;
END LOOP;
END p_procedure;
Is this the right process or is my code wrong???
Thanks
Manoj

What is wrong in having a COMMIT inside a loop? It might only increase the I/O, but the code does work right?The COMMIT says you've finished and can release resources, the loop says you haven't finished and still need them. It's asking for trouble (traditionally in the form of ORA-01555 "Snapshot too old" errors, which confuse developers who thought they were doing the database a favour by saving their work like it was MS Word). It can also complicate restartability, although perversely developers sometimes claim it is necessary in order to allow restarting if a long-running process fails (which it isn't) or to allow monitoring of how far it's got.
At the very least, try COMMIT WRITE BATCH NOWAIT ;)

Similar Messages

  • Returning SQL cursor from Stored Procedure

    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..

    RP wrote:
    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..It sounds like what you need is a ref cursor.
    First thing to remember though is that cursors do not hold any data (see: {thread:id=886365})
    In it's simplest form you would be creating a procedure along these lines...
    SQL> create or replace procedure get_data(p_sql in varchar2, p_rc out sys_refcursor) is
      2  begin
      3    open p_rc for p_sql;
      4  end;
      5  /
    Procedure created.
    SQL> var rc refcursor;
    SQL> exec get_data('select empno, ename, deptno from emp', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc;
         EMPNO ENAME          DEPTNO
          7369 SMITH              20
          7499 ALLEN              30
          7521 WARD               30
          7566 JONES              20
          7654 MARTIN             30
          7698 BLAKE              30
          7782 CLARK              10
          7788 SCOTT              20
          7839 KING               10
          7844 TURNER             30
          7876 ADAMS              20
          7900 JAMES              30
          7902 FORD               20
          7934 MILLER             10
    14 rows selected.
    SQL> exec get_data('select deptno, dname from dept', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc
        DEPTNO DNAME
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS
            50 IT SUPPORTWhich takes an SQL statement (as you said that both your queries were unrelated), and returns a ref cursor, and then your Java code would fetch the data using that cursor.
    Now, as for getting your rows to columns and combining two queries that do that... something along these lines...
    SQL> select * from x;
    C
    A
    B
    C
    SQL> select * from y;
    C
    D
    E
    F
    SQL> ed
    Wrote file afiedt.buf
      1  select x.col1, x.col2, x.col3
      2        ,y.col1 as col4
      3        ,y.col2 as col5
      4        ,y.col3 as col6
      5  from (
      6        select max(decode(rn,1,col1)) as col1
      7              ,max(decode(rn,2,col1)) as col2
      8              ,max(decode(rn,3,col1)) as col3
      9        from (select col1, rownum rn from (select * from x order by col1))
    10       ) x
    11  cross join
    12       (
    13        select max(decode(rn,1,col1)) as col1
    14              ,max(decode(rn,2,col1)) as col2
    15              ,max(decode(rn,3,col1)) as col3
    16        from (select col1, rownum rn from (select * from y order by col1))
    17*      ) y
    SQL> /
    C C C C C C
    A B C D E F... will do what you ask. For further information about turning rows to columns read the FAQ: {message:id=9360005}

  • Cursor in stored procedure fails

    Hi,
    In our application we have a stored procedure which is called with in parameters to generate data into some table. This procedure is being called from another procedure.
    This procedure has been used to generate data into the table without any problem since oracle 9i. Last year we have upgraded to oracle 11g after that this procedure is failing intermittently to generate data. When this procedure is executed 50 times it fails atleast once to generate data. If we rerun the procedure for the failed case it generates the data without any change to program code nor any change in underlying data. It doesn't fail if we rerun. Therefore we are unable to simulate the problem.
    Procedure has got a very simple code.
    proc1 (p1 date,p2 date) is
    begin
    for c1_rec in c1 (select col1,col2
    from x,y where x.......)
    loop
    end loop;
    end;
    First we thought for some reason this procedure was not executed at all. But it is not the case. Actually it calls the procedure but the cursor inside the procedure doesn't fetch any records. Also it doesn't report any oracle error.
    Appreciate if any one can help me in this.
    Thanks & Regards,
    Raja

    vaidyanathanraja wrote:
    4. If there is a logical error, the same procedure should not generate data when it is rerun. Behaviour should be the same at all times.Incorrect. Something like NLS settings for example can make the same code, behave differently. E.g. a date string is passed and implicitly converted to a date. And this will work for most dates from different session using different NLS settings (e.g. yyyy/mm/dd versus yyyy/dd/mm). And these sessions will provide different results using the same parameters calling the same application code.
    There are a number of such run-time factors that influences code.
    5. Failed means it didn't generate the expected output. Which means that there is a problem with that SQL being executed the way it is, with the parameters used. You need to isolate the problem further.
    6. Parameter values are right.Have you proved that by using a test case that runs the very same SQL via a test proc, using the same parameter, via a job? Ran that test case interactively via sqlplus?
    You need to pop the hood and isolate the problem.
    7. I came across one blog saying different behaviour for REF CURSOR between oracle 10g and 11g and he says it is oracle bug. I don't know whether it is applicable for this case also.Bahumbug. There are many Oracle bugs. As there is in all software. However, you have not provided any evidence of a bug.
    Application code is behaving inconsistently. That is the symptom. Oracle system code is not relevant until you can prove that the inconsistency is not in the application code, but lower down the call stack.

  • Cursor in stored procedure

    Hi,
    1. I am using a cursor XYZ to store some data into a variable @abc and then using this variable as one of the conditions in filling a #TEMP_TABLE in my STORE_PROC procedure. The #TEMP_TABLE does not get populated.
    It works fine when I create a temp table and run the same query outside of the stored procedure.
    Here is a sample:
    DECLARE CURSOR XYZ FOR
    SELECT DISTINCT column-name
    FROM database name..Table Name
    WHERE condition
    OPEN XYZ
    FETCH XYZ INTO @abc
    IF (@@sqlstatus = 2)
    BEGIN
    ........returns an error code
    END
    WHILE(@@sqlstatus = 0)
    BEGIN
    INSERT INTO #TEMP_TABLE
    SELECT
    FROM
    WHERE
    AND .............. = @abc
    END
    Please facilitate a solution as to how to get this to work in a stored procedure?
    Thank you,
    Developer.

    Seems you question is concerned with MS SQL Server syntax. Here is
    the Oracle forum. Nevertheless all you are doing can be completed
    using the single sql statement:
    INSERT INTO <<temp table>>
    SELECT ... FROM ...
    WHERE ...
    AND ... IN (SELECT UNIQUE column-name
    FROM database name..Table Name
    WHERE condition)
    Rgds.

  • Scrollable Cursor in Stored Procedure

    I am trying to implement a scrollable cursor that exists in a stored procedure. Here is my situation:
    o Oracle 9i (9.2.0.1.0) for both client and server.
    o OCI Interface in purely C++ environment
    o I am able to compile/link program with 9i client library, and successfully fetch data from a stored proc that contains a nonscrollable/forward only/traditional cursor without any problems.
    I have a stored proc that looks like this:
    procedure test(
    testcursor out cv_types.cv_fit_data
    ) as
    begin
    open testcursor
    for select data_id,
    text
    from data;
    end test;
    This is where I run into problems:
    First I allocate an OCIStmt handle and bind it to the proc. Then using the stmt handle that points to the proc, I bind a secondary handle that points to the cursor (testcursor above) by calling OCIBindByPos with type=SQLT_REF (See OCI ref manual on binding ref cursor). Next, I execute the proc via OCIStmtExecute with the mode=OCI_STMT_SCROLLABLE_READONLY using the statement handle that points to the procedure. Then I use that secondary stmt handle to fetch the rows via OCIStmtFetch2(). I am able to fetch the rows if I stick to OCI_FETCH_NEXT, but when I attempt to use any scrollable features such as OCI_FETCH_ABSOLUTE, it bails with an ORA-24391 error. Upon further investigation, I found out that this error occurs when the stmt is not executed with mode=OCI_STMT_SCROLLABLE_READONLY. The clincher is that I did execute in that mode... Has anyone been faced with a similar situation? Am I tackling this the wrong way? Any help, even pointers to any docs I missed on the subject, is greatly appreciated.
    Thanks,
    Bryan
    I am using OCI in C++ to fetch the data via OCIStmtFetch2(...) method.

    vaidyanathanraja wrote:
    4. If there is a logical error, the same procedure should not generate data when it is rerun. Behaviour should be the same at all times.Incorrect. Something like NLS settings for example can make the same code, behave differently. E.g. a date string is passed and implicitly converted to a date. And this will work for most dates from different session using different NLS settings (e.g. yyyy/mm/dd versus yyyy/dd/mm). And these sessions will provide different results using the same parameters calling the same application code.
    There are a number of such run-time factors that influences code.
    5. Failed means it didn't generate the expected output. Which means that there is a problem with that SQL being executed the way it is, with the parameters used. You need to isolate the problem further.
    6. Parameter values are right.Have you proved that by using a test case that runs the very same SQL via a test proc, using the same parameter, via a job? Ran that test case interactively via sqlplus?
    You need to pop the hood and isolate the problem.
    7. I came across one blog saying different behaviour for REF CURSOR between oracle 10g and 11g and he says it is oracle bug. I don't know whether it is applicable for this case also.Bahumbug. There are many Oracle bugs. As there is in all software. However, you have not provided any evidence of a bug.
    Application code is behaving inconsistently. That is the symptom. Oracle system code is not relevant until you can prove that the inconsistency is not in the application code, but lower down the call stack.

  • OCI8: returning cursors from stored procedures

    The short version of my question is:
    In OCI8, how do open a cursor from the database stored procedure, return it to my C++ program and fetch from it, given that in OCI8 cursors and cursor functions are becoming obsoleted?
    The long version of the same question is:
    I am converting my C++ code from the Oracle 7.3 OCI driver to the Oracle8 OCI driver. One thing I did very frequently in Oracle 7.3 OCI code is open a multi-row select cursor within a stored procedure and return that cursor to my program. In the program, I would then do the fetching with the returned cursor. This was very useful, as it allows me to change the queries in the stored procedure (for example, to append information to certain columns or make some data in all uppercase) without recompiling the application due to a changed SQL string.
    My 7.3 psuedocode is as follows:
    stored procedure def:
    TYPE refCurTyp IS REF CURSOR;
    FUNCTION LoadEmployeeData RETURN refCurTyp;
    stored procedure body:
    FUNCTION LoadEmployeeData RETURN refCurTyp IS
    aCur refCurTyp;
    BEGIN
    OPEN aCur FOR
    SELECT emp_id, emp_name
    FROM employee_table
    ORDER BY emp_name;
    return aCur;
    END;
    OCI code: // all functions are simplified, not actual parameter listing
    // declare main cursor variable #1 and return cursor variable #2
    Cda_Def m_CDAstmt, m_CDAfunction;
    // open both cursors
    oopen(m_CDAstmt, ...);
    oopen(m_CDAfunction, ...);
    // bind cursor variable to cursor #2
    oparse(&m_CDAstmt, "BEGIN :CUR := MYPACKAGE.LoadEmployeeData; END;");
    obindps(&m_CDAstmt, SQLT_CUR, ":CUR", &m_CDAfunction);
    // run cursor #1
    oexn(&m_CDAstmt);
    // bind variables from cursor #2, and fetch
    odefineps(&m_CDAfunction, 1, SQLT_INT, &m_iEmpId);
    odefineps(&m_CDAfunction, 2, SQLT_CHAR, &m_pEmpName);
    while (!ofen(&m_CDAfunction))
    // loop: do something with fetch
    // values placed in m_iEmpID and m_pEmpName
    This works perfectly, and has really helped to make my code more maintainable. Problem is, in Oracle 8 OCI both cursors and the cursor functions (such as oopen()) are becoming obsoleted. Now it uses statement and environment handles. I know I can still use Cda_Def and cursors--for a while--within OCI8, but I need to know the official up-to-date method of returning a cursor from the database and fetching within my C++ code. Any code fragment, or explanation of what I need to do in OCI8 would be appreciated (perhaps I need to bind to a statement handle instead? But the stored procedure still returns a cursor.)
    The Oracle8 OCI has a new SQLT_ type, SQLT_RSET, which the header file defines as "result set type". Unfortunately, it's almost completely undocumented in the official documentation. Am I supposed to use this instead of the obsolete SQLT_CUR?
    Thanks,
    Glen Mazza

    Email me diorectly and I will get you some code that might help. I fail to see the relevance of posting this type of information in the JDeveloper forum.

  • Importing function with multiple ref cursors in Stored Procedure of Oracle 12c database Using EF6

    Hi Good day!
    I can able to import function for stored procedure of oracle db and able to add the complex type and get the output but i tried to import the procedure which having two ref cursors and unable to retrieve the column information. Only able to retrieve the
    columns of first ref cursor.  Please help me to get the result of two ref cursors which acting as out parameters.

    Having to ref cursors return mutiple recordsets in an Oracle package is like haveng two resultsets return from a MS SQL Server sparc.
    The link may point you in the right direction.
    http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram

  • Extending a Cursor (for stored procedure)

    (Embedded image moved to file: PIC19643.PCX) Dan Christopher @ SUNLIFE
    03-13-97 04:39 PM
    I receive the following message when I try to extend a cursor for an
    execute of a stored procedure. I believe my problem has to do with using
    ODBC as my driver (to attach to a MS-SQL Server 6.5 database) , but does
    anyone have any other insight to what my problem may be.
    SYSTEM ERROR: Invalid state transition from FETCH to EXTENDED for statement of
    type qqdb_OdbcCursor.
    Class: qqdb_UsageException with ReasonCode: DB_ER_INVALIDSTATE
    Error #: [801, 152]
    Detected at: qqdb_Statement::ValidTransition
    Last TOOL statement: method w_connect.ExecStoredProc, line 53
    Error Time: Thu Mar 13 13:55:59
    Exception occurred (remotely) on partition "Dan_Connect_CL0_Part1",
    (partitionId = 210EC99B-811A-11D0-8D72-82F2A190AA77:0x22f:0x20, taskId =
    [210EC99B-811A-11D0-8D72-82F2A190AA77:0x23d:0x3.25]) in application
    "Forte
    Runtime", pid 314 on node 543SZAD in environment dusgroup.
    Here is a example of my code.
    constant NUM_ROWS_FETCH = 2; //default to fetch 50 rows
    //at a time.
    l_inputDataSet :DBDataSet = new; //input parameters for
    Forte
    l_statementtype :integer;
    l_return :integer; //return value for
    open/extend
    //cursor functions
    l_numRows :integer; //the number of rows fetch
    l_DBStatement :DBStatementHandle; //statement handle for
    sp
    l_statementtype = DB_CV_EXECUTE ;
    l_DBStatement = p_dbsession.Prepare(
    commandString = p_exec,
    inputDataSet = l_inputdataset,
    cmdType = l_statementtype);
    // fill in the parameter values
    for i in 1 to p_parameters.items do
    //integer parameter
    if (p_parameters.GetParmIndicator() = 'I') then
    l_inputdataset.SetValue(position = i,
    Value = p_parameters[i].GetParmValue().integervalue);
    else
    l_inputdataset.SetValue(position = i,
    Value = p_parameters[i].GetParmValue());
    end if;
    end for;
    //open the cursor
    l_return = p_dbsession.OpenCursor(
    StatementHandle = l_DBStatement,
    inputDataSet = l_inputdataset,
    resultDataSet = p_outputdataset);
    // Continue to Fetch and Extend the Cursor untill all rows have been
    retrieved.
    while (l_return != DB_RS_NONE) do
    l_numRows = p_dbsession.FetchCursor(
    StatementHandle = l_DBStatement,
    resultDataSet = p_outputdataset,
    maxRows = NUM_ROWS_FETCH);
    if (l_numRows = NUM_ROWS_FETCH) then //extend the cursor
    l_return = p_dbsession.ExtendCursor(
    StatementHandle = l_DBStatement,
    resultDataSet = p_outputdataset);
    else
    exit;
    end if;
    end while;
    //close the cursor
    p_dbsession.CloseCursor(statementHandle = l_DBStateMent);
    return l_numRows;

    Hi Dan,
    Thanks for the Calrification on Cursors, We solved it here.
    As for your Extend problem goes the Fetch should go outside the while
    loop I think.
    You first fetch and then get the next data set in a loop. I feel
    that this should solve your problem.
    Thankx
    Bala
    [email protected]
    Sage Solutions
    353 Sacramento
    Suite 1360
    San Francisco
    CA 94111.

  • UPDATE via REF CURSORS in STORED PROCEDURE

    Hello,
    Can I Get REF CURSOR as INPUT in STORED PROCEDURE and make an UPDATE according the input data ?
    Thanks

    Having to ref cursors return mutiple recordsets in an Oracle package is like haveng two resultsets return from a MS SQL Server sparc.
    The link may point you in the right direction.
    http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram

  • Reports 3.0, Ref Cursor from stored procedure

    I have a problem trying to use Ref Cursor as datasource (i.e.
    Ref Cursor Query) in Reports 3.0
    I have created a stored package with a function which returns
    Ref Cursor.
    That function just opens the cursor and returns it to the
    calling module.
    Reports recognizes returned cursor - it creates a group for that
    query, with all columns, than I built
    a layout model - everything is OK on that stage.
    During the execution of that report (from previewer or using
    Reports Runtime) I got an error message like that:
    REP-0065 Virtual Memory System Error
    REP-0200 Cannot allocate enough memory cavaa22
    Error's description does not correspond the reality :) - there
    is enough virtual & physical memory according to
    Task Manager information.
    So, that does not work when this package is stored one.
    When I create the package on the client side - in Reports -
    everything works just fine.
    Cursor is opened with a very simple query, selecting records
    from the very simple table having only one record.
    There is no code written which closes that cursor or fetches the
    records.
    Client platform: WinNT 4.0 SP3
    Oracle Reports: 3.0.5.8.0
    Oracle Server: Oracle8 8.0.5.0.0 (and I tried also on Oracle7
    7.3.4.3.0)
    Thanx.
    null

    Sara,
    GTT (Global Temporary Tables) in Oracle work a different way compared to SQL Server and Informix. There you can create temporary tables on the fly and drop them on the fly.
    Here you should (note, you don't have to, but, best practice says that you should) create the table using the syntax...
    create global temporary table.....
    Once you create it, even though it looks like persistent table, it's not. It will have it's own individual data PER SESSION . You have two types of GTTs:
    ON COMMIT PRESERVE ROWS and ON COMMIT DELETE ROWS (they work in slightly different way).
    Look up GTTs here:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/tables.htm#sthref2213
    HTH,
    Rahul

  • Ref cursors for stored procedure

    Hi every body,
    I am new one,I am in learning stage.
    My java developer was ask me give set of results.
    i am using in my code sys_refcursor, my questions are.
    SQL> create or replace procedure sysref(p_out out sys_refcursor) is
    2 begin
    3 open p_out for select empno,ename from employee;
    4 end;
    5 /
    I am using the procedure like above procedure.
    1) How to use ref cursors in procedure. what is the main use.
    2) How to close ref cursors in procedure.If it is need.
    3) How to use exceptions in procedures for ref cursors.
    Give me one example with complete structure.
    Please help me
    new one
    Edited by: subba on Aug 19, 2010 12:08 AM
    Edited by: subba on Aug 19, 2010 12:09 AM

    subba wrote:
    1) How to use ref cursors in procedure. what is the main use.All SQL in Oracle are parsed as cursors in the Shared Pool. The client code (be that PL/SQL or Visual Basic or Java) gets a handle or reference to this SQL cursor on the server.
    Using this handle, the client can fetch rows using the cursor (the cursor is like a program - the executable binary version of the source SQL code).
    Clients implement their interfaces with this SQL cursor handle in different ways. PL/SQL alone supports:
    - implicit cursor handles
    - explicit cursor handles
    - DBMS_SQL cursor handles
    - reference cursor handles
    Why so many? Different tools for different jobs. Each has its pros and cons and each is suited for specific (and different) types of problems.
    A ref cursor is special in that PL/SQL can pass this SQL cursor reference handle to an external client to use - like Java.
    Why?
    The basic concept is that of abstraction. Removing the complexities of SQL and the database design and SQL optimisation from the Java code. Instead, Java calls a PL/SQL proc. This proc creates the SQL cursor, and uses a reference cursor variable to store the SQL cursor handle. It can then pass this to Java. This means that the entire SQL is encapsulated in the PL/SQL proc. We can now modify it, optimise it, support data models changes in the database via the PL/SQL proc... all without even having to recompile the Java code that makes the call and consumes the ref cursor the PL/SQL proc gives it.
    2) How to close ref cursors in procedure.If it is need.Yes. A very important factor - well spotted.
    As PL/SQL can pass ref cursors to external clients. it does not automatically close these cursors. It does not know when the client has consumed the cursor. It will only close it when the cursor is still open, when the Oracle server session is terminated.
    So it is important that the client (Java in this case) closes the cursor when done. If not, the cursor will remain open, will continue to occupy server resources... and if the client opens more and more of these cursors, the server process will run out of resources.
    Cursor leakage by Java developers are common - and can simply be avoided by closing the cursor once the Java code has consumed it.
    3) How to use exceptions in procedures for ref cursors.No. Why? Why would you want to deal with the exception in a PL/SQL proc? The Java code wants to open that cursor. It knows why. It knows what to do when that cursor fails or is empty. It interacts with the user. How is the PL./SQL proc, whose only function is to construct the SQL and pass the cursor handle to Java, to know any of this?
    Exceptions in this regard should typically be handled in Java. Not in PL/SQL.
    Of course, if that PL/SQL proc has parameters, it also needs to validate these and it needs to raise application exceptions to inform the Java caller when these parameters are invalid.
    But actually catching exception in this case... does not make much sense. As what can the PL/SQL do about the error when it is a "server" and Java is the "client"?
    It is like saying that the Oracle Server should handle all exceptions when TOAD is used and incorrect SQL is passed to it. How does it make sense for Oracle to process SQL errors and the TOAD client not getting any results from a wrong SQL and not knowing that there was even an error with that SQL?

  • For oracle cursor and stored procedure.

    Hi,
    I wanted to call a PL/SQL function that opens a cursor and gets a cursor
    back as a Java result set.Actually there is a readymade program in
    http://www.oradoc.com/ora816/java.816/a81354/samapp5.htm#1016411
    in the name RefCursorExample.java
    Now what I wanted to know is in weblogic how to do that.
    For example I would like you to help me to give the weblogic equivalent of a
    single line in that program.
    call.registerOutParameter(1, OracleTypes.CURSOR);
    Instead of OracleTypes.CURSOR...what should I write for weblogic JDriver for
    oracle.
    Please refer to my program in the attachment. FYI weblogic is already
    running when I execute the program and it creates oracle connection pools.
    Please also look at the exceptions it throws below.
    Exceptions are
    Exception java.sql.SQLException: ORA-06550: line 1, column 15:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 9:
    PL/SQL: Statement ignored
    java.sql.SQLException: ORA-06550: line 1, column 15:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 9:
    PL/SQL: Statement ignored
    at
    weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.j
    ava:76)
    at
    weblogic.jdbc20.rmi.internal.WLStub2z3m13133166452s5z42a5c4u4a3b1v.ex
    ecute(WLStub2z3m13133166452s5z42a5c4u4a3b1v.java:415)
    at
    weblogic.jdbc20.rmi.internal.CallableStatementStub.execute(CallableSt
    atementStub.java:454)
    at
    weblogic.jdbc20.rmi.SerialPreparedStatement.execute(SerialPreparedSta
    tement.java:401)
    at OracleDataSource.main(OracleDataSource.java:49)
    I would be great if you can help me out.
    Sincerely,
    Praveen.C
    [OracleDataSource.java]

    Also, see this KBA.
    And KBA 1525432
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • 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

  • Retrieving cursor from a stored procedure

    Hi,
    Is there any means to retrieve a cursor from a stored procedure using java.sql.* package, without using database specific type code like OracleTypes.CURSOR?
    Regards,
    Shalin.

    Hi,
    I had some across this problem some time ago. Although, there is no direct answer to this solution, there is a "kloog" that you can apply.
    Please note that the signature for registerOutParameter(int parameterIndex, int sqlType), and note that where ever sqlType is mentioned it is an int.
    Now JDBC is an interface and the implementation is given by Oracle. So to register an "out" parameter all you have to do is registerOutParameter(1, OracleTypes.CURSOR). It works!
    Or otherwise try and find out what the int value of CURSOR is and replace. This is because not all databases can support returning a "cursor" type, since ORACLE and few other databases have a concept of "STORED PROCEDURE" and PLSQL is specific to ORACLE.
    I hope this helps!
    Cheers,
    John.

  • How to create a LOV based on a stored procedure returning a cursor

    Hello,
    I've tried to search the forum, but did not find much. We are facing a problem of large LOVs and creating large TMP files on the app server. Our whole application is drived by store procedures. LOVs are built manually by fetching data from cursors returned from stored procedures. That creates the issue when whole LOV needs to be stored in the memory and thus the TMP files.
    Is there anyway how to create LOV based on a procedure returning cursor ?
    Thank you,
    Radovan

    Hello,
    As of now we populate the record group by looping through the ref cursor and adding rows into it. Is there a better way? That forces the whole record group to be stored in a memory on the app server.
    Thank you,
    Radovan

Maybe you are looking for