Unexpected "ORA-01001: invalid cursor" error

I have a Pro*C application that basically fetches from a cursor, does a bunch of work with that row, does a "delete from <table> where current of <cursor name>", then loops back, fetches, the next row, etc., and finally closes the cursor once all the rows have been processed.
One of our clients is getting an 'ORA-01001' error on the "DELETE FROM <table> WHERE CURRENT OF <cursor>" statement. This is long-standing, frequently executed code at 100+ clients and I've never had a problem with this statement before. The client is consistently getting this error on a particular row from this cursor, but other rows processed with the same cursor are processing successfully.
Unfortunately, I do not have direct access to the client's database, so I cannot debug directly, but I've placed print statements around the only place in my application's code that explicitly closes the cursor. A log generated on a run that threw the 1001 error confirmed that the cursor is NOT being explicitly closed by my application by an "EXEC SQL CLOSE <cursor>" statement.
Likewise, I put print statements around all the COMMITs and ROLLBACKs in my application, and none of these showed in the logs either.
My application does make a call to a client-customized PL/SQL function that they recently changed. However, I have a copy of the clients function and there are not any explicit COMMIT, ROLLBACK, ANALYZE, ALTER, DROP, REPLACE, TRUNCATE or CREATE statements that would implicitly commit and close the cursor.
Here are potential problems that I have ruled out:
-Oracle OPEN_CURSORS parameter - It appears that if this were the problem, the error would be an ORA-1000, not 1001. Please correct me if I am wrong here.
-Pro*C MAXOPENCURSORS parameter - I compiled a version with a MAXOPENCURSORS value that is higher than the client's OPEN_CURSORS setting. If this were the problem, the error should have switched to the ORA-1000 error when I increased the parameter. It remained as an ORA-1001.
Next steps:
-What could cause a cursor to close other than explicit COMMIT, ROLLBACK, ANALYZE, ALTER, DROP, REPLACE, TRUNCATE or CREATE statements?
-Is there anything I can run, such as a database trace, that will show me exactly when the cursor is being closed? I admittedly don't know a lot about DB traces.
-Anything else I should check? Any other information I should provide?
Thanks ahead of time for any help!

Chandrakaanth Ramamurthy wrote:
Does the client customized PL/SQL block contain EXIT
Exit will end up issuing a commit and hence this could be an issue.Exit is not used in the customized function.
Chandrakaanth Ramamurthy wrote:
Also please check that commit and roll back are placed at the end of the loop.The only commit/rollback is after the loop is over is finished.
I actually just figured out the issue. Turns out the cursor just hadn't been opened due to a very unique data condition... facepalm You know what happens when you assume things, right? :)
Thanks for the help anyway!

Similar Messages

  • "ORA-01001 Invalid Cursor" error

    Platform: oracle 8.X on ibm aix and java client code from
    windows NT.
    JDBC DRIVER: JDBC Oracle thin driver version 1.2.
    when i execute a Sql satement with Cursor expression from the
    java client code with XSU it returns an XML DOM But if the
    CURSOR EXPRESSION IN THE SQL QUERY RETURNS EMPTY ROWS i get
    back an error node with "ORA-01001 Invalid Cursor" error
    message.i had aslo set the setNullAttributes(true) property
    on oraclexmlquery.
    Interestingly, if i exceute the same query in the SQL plus
    it returns the column names with no rows.
    is there any way where i can get xml document with table
    structure, when there are no rows instead of ORA error message.
         

    This is just a guess,
    all you cursors are being opened regardless of any condition, for example;
    OPEN CUT(:NEW.LAYOUT_NO);
    OPEN DET(:NEW.LAYOUT_NO);
    OPEN ITM(:NEW.LAYOUT_NO);
    OPEN LOT(:NEW.LAYOUT_NO);
    OPEN DTN(:NEW.LAYOUT_NO, :NEW.CUT_NO, :NEW.NOTE);UNA however is opened after a condition;
    IF DTN%NOTFOUND THEN
      /** start --added for cha 2011-3172 6/14/2011 **/
          OPEN UNA(:NEW.LAYOUT_NO, :NEW.ACCOUNT_NO);All cursors arel however closed regardless, i.e. they are all assumes to be open;
      CLOSE CUT;
      CLOSE DET;
      CLOSE DTN;
      CLOSE ITM;
      CLOSE LOT;
      CLOSE STAT;
      CLOSE UNA;So I think you are closing the UNA cursors wen it is in fact not open.
    So, move the "CLOSE UNA;" line of code to before the END IF; on line 278, since that is when it will definitely be open.

  • Oracle 10g EE Export Results in ORA-01001: invalid cursor Error

    Hi,
    I'm quite new to Oracle 10g and OCS10g. We have a crippled/corrupt SYSAUX tablespace (data file 3) which cannot be recovered using recover
    command anymore. So metalink support instructed us to do a export of the metadata of the working tablespace which contains our system data (we are in configuration stage for OCS 10g 10.1.2) via transportable tablespaces so that I can just recreate the database in DBCA and import the metadata. So after I made a cold backup, set the "transportable" tablespaces to "READ ONLY" mode, I proceeded w/ the export command which resulted in an error, please see below:
    $exp \'sys/********@ocs10gSID as sysdba\' parfile=transport.par
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.4.2 -
    Production
    With the Partitioning, Real Application Clusters, OLAP and Data Mining options
    Export done in US7ASCII character set and AL16UTF16 NCHAR character set
    server uses AL32UTF8 character set (possible charset conversion)
    Note: table data (rows) will not be exported
    About to export transportable tablespace metadata...
    EXP-00008: ORACLE error 1001 encountered
    ORA-01001: invalid cursor
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 899
    ORA-06512: at "SYS.DBMS_SQL", line 19
    ORA-06512: at "SYS.DBMS_TTS", line 811
    ORA-00376: file 3 cannot be read at this time
    ORA-01110: data file 3: '/ocfs/oradata/OCS/datafile/o1_mf_sysaux_2mgzbr51_.dbf'
    ORA-06512: at "SYS.DBMS_PLUGTS", line 1444
    ORA-06512: at line 1
    Anyone encountered this problem before? Any recommendations or tips to get this working?
    I checked this url:"http://luhartma.blogspot.com/2006/05/how-to-check-if-tablespace-is.html"
    And when I try to follow the instructions and check on of the tablespace I set to and verified to be in "READ ONLY" mode, I get the same error.
    SQL> connect / as sysdba
    Connected.
    SQL> exec dbms_tts.TRANSPORT_SET_CHECK('PORTAL',TRUE)
    BEGIN dbms_tts.TRANSPORT_SET_CHECK('PORTAL',TRUE); END;
    ERROR at line 1:
    ORA-01001: invalid cursor
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 899
    ORA-06512: at "SYS.DBMS_SQL", line 19
    ORA-06512: at "SYS.DBMS_TTS", line 811
    ORA-00376: file 3 cannot be read at this time
    ORA-01110: data file 3: '/ocfs/oradata/OCS/datafile/o1_mf_sysaux_2mgzbr51_.dbf'
    ORA-06512: at "SYS.DBMS_TTS", line 840
    ORA-06512: at line 1
    Hope someone can help on this or at least provide a suggestion. Data file 3 above is the reason we are doing a transportable tablespace export & db recreation.
    BTW what we have is:
    OCS 10g 10.1.2 w/ Oracle RDBMS 10g Enterprise Edition 10.1.0.4.2
    RHEL4 Update2
    Thanks in advance.
    Regards,
    -Kenth

    Hi,
    The status is "RECOVER" we have actually tried to recover but unfortunately the archive logs that were needed were on disks and were lost during one of the server hardware failures. Actually that is the reason why metalink support recommended this route for getting everything in order since we don't have any application data in SYSAUX yet.
    Thanks.

  • ORA-01001: invalid cursor (Inbound jdbc adapter XI 2.0)

    Hello, I get the error ORA-01001: invalid cursor when I try to delete the data in interface table in an ORACLE database. Has anybody an idea of what maybe the problem.
    here the text...
    14:41:59 (4225): Confirm with statement "delete * from sap_interface.aswaa00f"
    14:41:59 (4226): ERROR: Confirm action failed with error "java.sql.SQLException: ORA-01001: invalid cursor
    regards
    Ernesto Duran

    Hello Prasad, thank you for your response. The problem (limitation) was that the adapter (or the driver) can only update natives ORACLE tables and the table I wanted to update was a gateway table to an external program.
    regards
    Ernesto Duran

  • ORA-01001: invalid cursor

    I have the below code I am trying to execute and get the error ORA-01001: invalid cursor
    create or replace PROCEDURE TESTUPDATE(pNAME VARCHAR2,pID NUMBER) IS
      CN NUMBER;
       CURSOR C1 IS
       SELECT CODE,SOPTION,SFILE
              STREET1,
              STREET2
       FROM TABLE1
       WHERE CODE = '10';
       CURSOR C2 IS
       SELECT CODE,
              STREET1,
              STREET2
       FROM TABLE2
        WHERE CODE = '10;
        C1_REC C1%rowtype;
        C2_REC C2%rowtype;
    BEGIN
       OPEN C1;
       FETCH C1 INTO C1_REC;
       SELECT COUNT(*) INTO CN FROM TABLE2
       WHERE  code =  '10'
          IF ( C1_REC.SOPTION = 'C' )  THEN  --- SOPTION is 'C"
             IF (CN = 0) THEN 
                IF (C1_REC.SFILE = 'FILE') THEN
                   INSERT INTO TABLE2(ASSIGNED) VALUES('Y');
                    ELSE    
                   INSERT INTO TABLE2(ASSIGNED) VALUES('N');              
                END IF;   
             ELSE    /* CN > 0 */
               OPEN C2;
               FETCH C2 INTO C2_REC;
               IF (C1_REC.SFILE = 'FILE') THEN
                 IF ( C1_REC.STREET1 IS NOT NULL OR
                     C1_REC.STREET2 IS NOT NULL ) AND
                   ( C1_REC.STREET1 !=  C2_REC.STREET1 OR
                     C1_REC.STREET2 !=  C2_REC.STREET2) THEN
                  UPDATE TABLE2
                  SET    ASSIGNED = 'I';
                 END IF;
           ELSE  /*IS NOT EQUAL TO 'FILE'*/
                 IF ( C1_REC.STREET1 IS NOT NULL OR
                     C1_REC.STREET2 IS NOT NULL ) AND
                   ( C1_REC.STREET1 !=  C2_REC.STREET2 OR
                     C1_REC.STREET2 !=  C2_REC.STREET2) THEN
                  UPDATE TABLE2
                  SET    TABLE2_status_ind = 'N';
               END IF;
             END IF;
           END IF;
          ELSIF ( C1_REC.SOPTION = 'CR' ) THEN   /*SOPTION is 'CR"*/
             IF (CN = 0) THEN
                IF (C1_REC.SFILE = 'FILE') THEN
                   INSERT INTO TABLE2(ASSIGNED) VALUES('Y');
                    ELSE    
                   INSERT INTO TABLE2(ASSIGNED) VALUES('N'); 
                END IF;
         ELSE    /* CN > 0*/
               OPEN C2;
               FETCH C2 INTO C2_REC; 
               IF (C1_REC.SFILE = 'FILE') THEN
                 IF ( C1_REC.STREET1 IS NOT NULL OR
                     C1_REC.STREET2 IS NOT NULL ) AND
                   ( C1_REC.STREET1 !=  C2_REC.STREET2 OR
                     C1_REC.STREET2 !=  C2_REC.STREET2) THEN
                  UPDATE TABLE2
                  SET    TABLE2_status_ind = 'I';
                  END IF;             
            ELSE  /* IS NOT EQUAL TO 'FILE'*/
                 IF ( C1_REC.STREET1 IS NOT NULL OR
                     C1_REC.STREET2 IS NOT NULL ) AND
                   ( C1_REC.STREET1 !=  C2_REC.STREET2 OR
                     C1_REC.STREET2 !=  C2_REC.STREET2) THEN
                  UPDATE TABLE2
                  SET    TABLE2_status_ind = 'I';
                  END IF; 
           END IF;
         END IF;
    END IF;
    CLOSE C1;
    CLOSE C2;     
    END IF;
    EXCEPTION WHEN NO_DATA_FOUND THEN
                       dbms_output.put_line('e1');
      CLOSE C1;
    WHEN OTHERS THEN
            CLOSE C1;
            dbms_output.put_line('e2');
    END;when I have the soption as CR and cn=0, I get the error invalid cursor. Please help me with changes to the code to overcome this error
    thanks
    Edited by: 890563 on 14 Nov, 2012 5:37 AM
    Edited by: BluShadow on 14-Nov-2012 13:39
    added {noformat}{noformat} tags to make code readable.  After 48 questions (of which you still have 40 unanswered for some reason?) and a year on the forums, we would expect you to have learnt how to ask questions... but just in case you missed it... read here: {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I am sorry for posting such confusing code. I changed the last part of code code to
    END IF;
    END IF;
    CLOSE C1;
    CLOSE C2;
    END IF;
    END IF;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    dbms_output.put_line('e1');
    CLOSE C1;
    WHEN OTHERS THEN
    CLOSE C1;
    dbms_output.put_line('e2');
    END;
    and it worked with out errors
    Thanks

  • Proxy connections getting ORA-01001: invalid cursor

    All,
    I am having tremendous difficulty using Oracle proxy connections under WebSphere 5.1. The problem appears to be that the proxy sessions (or the logical connections) are not being closed properly resulting in 'invalid cursor' and 'fetch out of sequence' exceptions.
    Here's the sequence of events:
    Environment
    AppServer : Websphere 5.1
    Database : Oracle 10gR2
    Datesource: oracle.jdbc.pool.OracleConnectionPoolDataSource
    Start up application server
    Check the sessions on the db
    USERNAME                       TYPE       SERVER    MODULE
    * APAX                           USER       DEDICATED
    * APAX                           USER       DEDICATED
    SYS                            USER       DEDICATED sqlplus@apaxIIdb (TNS V1-V3)* = connection pool sessions
    Step 1: getting the connection
    // lookup datasource in jndi
    Connection myConnection = myDataSource.getConnection();Step 2: opening a proxy connection
    Properties myProperties = new Properties();
    myProperties.put("CONNECTION_TAG", aPrincipal);
    myProperties.put("PROXY_USER_NAME", aPrincipal);
    OracleConnection myOracleConnection =
      (OracleConnection) WSJdbcUtil.getNativeConnection((WSJdbcConnection) myConnection);
    myOracleConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, myProperties);Step 3: check the sessions on the db
    SQL>  select username, type, server, module
    from v$session
    where type != 'BACKGROUND'
    and username is not null
    order by username;
    USERNAME                       TYPE       SERVER    MODULE
    APAX                           USER       DEDICATED
    APAX                           USER       DEDICATED
    APAX                           USER       DEDICATED
    SYS                            USER       DEDICATED sqlplus@apaxIIdb (TNS V1-V3)
    * USER1                          USER       PSEUDO* = proxy connection
    Step 4: prepare and execute query
    myResultSet = myStatement.executeQuery();Exception thrown: java.sql.SQLException: ORA-01001: invalid cursor
    SQLState = 72000
    vendorCode = 1001
    Session information:
    USERNAME                       TYPE       SERVER    MODULE
    APAX                           USER       DEDICATED
    APAX                           USER       DEDICATED
    SYS                            USER       DEDICATED sqlplus@apaxIIdb (TNS V1-V3)
    * USER1                          USER       DEDICATED* = proxy session appears to have changed
    Step 5: clear up
    OracleConnection myOracleConnection =
      (OracleConnection) WSJdbcUtil.getNativeConnection((WSJdbcConnection) aConnection);
    myOracleConnection.close(OracleConnection.PROXY_SESSION);
    myOracleConnection.close();Check sessions again
    USERNAME                       TYPE       SERVER    MODULE
    APAX                           USER       DEDICATED
    APAX                           USER       DEDICATED
    SYS                            USER       DEDICATED sqlplus@apaxIIdb (TNS V1-V3)There are no Oracle udump files or other tracing information.
    Any ideas?

    We were getting ORA-01001 error messages that didn't appear to make sense when calling certain pl/sql procedures from a application running on a Weblogic/Apache platform. The errors would not occur when we invoked the same procedures via script from a standalone SQL client.
    We were able to put an end to the Web application errors by upgrading our jdbc driver from 10.1.0.4.0 to 10.2.0.1.0.

  • Getting ORA-01001: invalid cursor when I try to parse my SQL statement with DBMS_SQL

    -- To modify this template, edit file PROC.TXT in TEMPLATE
    -- directory of SQL Navigator
    -- Purpose: Briefly explain the functionality of the procedure
    -- MODIFICATION HISTORY
    -- Person Date Comments
    TYPE column_find IS VARRAY(999) of VARCHAR2(4);
    v_client_column varchar2(4);
    v_errorcode NUMBER;
    v_errortext VARCHAR2(200);
    i number :=0;
    V_COLUMN_NAME varchar2(20);
    V_COLUMN_NAME2 varchar2(20);
    v_SQL_STMT varchar2(2000);
    v_c_hndl integer;
    v_Client_ID varchar2(200);
    column_name varchar2(20);
    execute_feedback integer;
    mal material_attribute_pre_load%
    ROWTYPE;
    local_var varchar2(200);
    clienttab DBMS_SQL.DATE_TABLE;
    client_column column_find := column_find();
    -- Declare program variables as shown above
    BEGIN
    --client_column := column_find();
    v_c_hndl := DBMS_SQL.OPEN_CURSOR;
    while i < 999
    LOOP
    i := i + 1;
    client_column.EXTEND;
    client_column(i) := CONCAT('c',i);
    dbms_output.put_line(client_column(i));
    BEGIN
    dbms_output.put_line('Starting SQL_STMT.');
    v_SQL_STMT := 'SELECT :column_name FROM
    MATERIAL_ATTRIBUTE_PRE_LOAD WHERE :column_name2 = :v_Client_ID';
    dbms_output.put_line('Starting DBMS_SQL.PARSE.');
    DBMS_SQL.PARSE(v_c_hndl,v_SQL_STMT,DBMS_SQL.NATIVE);
    dbms_output.put_line('Starting DBMS_SQL.BIND_VARIABLE.');
    DBMS_SQL.BIND_VARIABLE
    (v_c_hndl,'v_Client_ID','Client ID');
    DBMS_SQL.BIND_VARIABLE
    (v_c_hndl,'column_name',client_column(i));
    DBMS_SQL.BIND_VARIABLE
    (v_c_hndl,'column_name2',client_column(i));
    dbms_output.put_line('Starting DBMS_SQL.DEFINE_ARRAY.');
    DBMS_SQL.DEFINE_ARRAY(v_c_hndl,1,clienttab,999,1);
    execute_feedback := DBMS_SQL.EXECUTE_AND_FETCH
    (v_c_hndl);
    DBMS_SQL.CLOSE_CURSOR(v_c_hndl);
    dbms_output.put_line
    EXCEPTION
    WHEN OTHERS THEN
    v_errorcode := SQLCODE;
    v_errortext := SUBSTR(SQLERRM,1,200);
    dbms_output.put_line('DISPLAY_ERROR'||SUBSTR(TO_CHAR
    (v_errorcode)||v_errortext,1,30));
    END;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    v_errorcode := SQLCODE;
    v_errortext := SUBSTR(SQLERRM,1,200);
    dbms_output.put_line('DISPLAY_ERROR'||SUBSTR(TO_CHAR
    (v_errorcode)||v_errortext,1,30));
    END; -- Procedure COLUMN_FIND

    I'm using Oracle Database Express edition (latest version from the website afaik), logging into the web interface (using unique account I created after setup[not System], gave it All rights), clicking on SQL > SQL Commands > Enter commands.
    I can't run each insert individually, that is only 1 table out of 8 tables, and I probably need to be able to run the entire script (which is actually headed by a sequence of Drop Table commands) sometimes, to refresh the data back to original values in case I stuff things up. The code was originally provided in a text file called bookscript.sql, but I haven't had any success importing or uploading that file into Oracle XE, if I use SQL > SQL Scripts > Upload, the file uploads, I then click on it and click on Run, but nothing seems to happen. (File is shared [read-only] here: https://docs.google.com/leaf?id=0B7IgBXIBNxw3OTY1ZTdmNGQtMjEwYi00YmRmLTkwZjItODZkYmYxODNkMTk4&hl=en_US).
    Would love any guidance as to how to modify my environment or how to input the code differently to get it running, it works fine in the hosted environment at Uni, it's an Oracle class (textbook is Guide to Oracle 10g). Lecturer doesn't seem to know much about setting up Oracle, only working in a functioning environment.

  • "Invalid Cursor" Error in Form

    Hi,
    I wrote a procedure that take a REF CURSOR as an IN OUT argument. This procedure does an "OPEN cursor FOR qry" with a dynamic query:
    OPEN l_cursor FOR
           'SELECT A '||
             'FROM B '||
            'WHERE C = :l_var'
         USING myVar;After calling the procedure, I do a LOOP with FETCH.
    It works well when I use it in SQL*Plus with DBMS_OUTPUT but it returns a "ORA-01001 invalid cursor" error in Forms.
    Any help is welcome!
    Regards,
    Olivier.

    I found a solution on Metalink:
    Note:170881.1
    Note: 1007395.6
    Olivier.

  • Invalid Cursor error when modifying Assignment details - Transfer workflow

    Hi,
    We're trying to submit a Transfer transaction but if we try to modify any field in the Assignment details screen, we're getting a system error, and sometimes we see ORA-01001: invalid cursor error. We have already checked the database objects (procedures, packages, triggers) and we don't see any code which has an invalid use of a cursor. Does anyone have a clue on the cause of this error?

    This is just a guess,
    all you cursors are being opened regardless of any condition, for example;
    OPEN CUT(:NEW.LAYOUT_NO);
    OPEN DET(:NEW.LAYOUT_NO);
    OPEN ITM(:NEW.LAYOUT_NO);
    OPEN LOT(:NEW.LAYOUT_NO);
    OPEN DTN(:NEW.LAYOUT_NO, :NEW.CUT_NO, :NEW.NOTE);UNA however is opened after a condition;
    IF DTN%NOTFOUND THEN
      /** start --added for cha 2011-3172 6/14/2011 **/
          OPEN UNA(:NEW.LAYOUT_NO, :NEW.ACCOUNT_NO);All cursors arel however closed regardless, i.e. they are all assumes to be open;
      CLOSE CUT;
      CLOSE DET;
      CLOSE DTN;
      CLOSE ITM;
      CLOSE LOT;
      CLOSE STAT;
      CLOSE UNA;So I think you are closing the UNA cursors wen it is in fact not open.
    So, move the "CLOSE UNA;" line of code to before the END IF; on line 278, since that is when it will definitely be open.

  • Invalid Cursor Error

    I have a table called cdd_merge_children where the comments field contains the following SQL.
    SELECT EVENT_ID FROM EVENT WHERE ACCOUNT_ID = :ACCOUNT_NO
    In my procedure I am doing the following:
    --get the comments from the cdd_merge_children table where CDD_MERGE_CHILDREN_TYPE
    --is of type 3. type 3 are a replica of type 2's for audit/history purposes 
    SELECT DISTINCT COMMENTS
    INTO ls_comments
    FROM CDD_MERGE_CHILDREN
    where table_name = ps_tablename
    and CDD_MERGE_CHILDREN_TYPE = 3 ;
    --get the comments from the table and execute the dynamic sql using the looser.
    OPEN col_cv FOR ls_comments USING gvloosingaccount ;
    --dump the curosr values in the table
    FETCH col_cv BULK COLLECT INTO loosingvals ;
    For some reason or the other when I try doing the fetch I am getting invalid cursor or ORA-01001: invalid cursor error. WHY WHY
    Please help !

    You cannot bulk-fetch from a cursor into a collection of records, you can only bulk-fetch from a cursor into one or
    more collections:
    DECLARE
    TYPE NameList IS TABLE OF emp.ename%TYPE;
    TYPE SalList IS TABLE OF emp.sal%TYPE;
    CURSOR c1 IS SELECT ename, sal FROM emp WHERE sal > 1000;
    names NameList;
    sals SalList;
    BEGIN
    OPEN c1;
    FETCH c1 BULK COLLECT INTO names, sals;
    END;
    You cannot however,
    DECLARE
    TYPE NameList IS TABLE OF emp.ename%TYPE;
    names NameList;
    salary emp.sal%TYPE;
    TYPE DeptRecTab IS TABLE OF dept%ROWTYPE;
    dept_recs DeptRecTab;
    CURSOR c1 IS
    SELECT deptno, dname, loc FROM dept WHERE deptno > 10;
    BEGIN
    SELECT ename, sal BULK COLLECT INTO names, salary; -- illegal target
    BEGIN
    OPEN c1;
    FETCH c1 BULK COLLECT INTO dept_recs; -- illegal
    END;
    Ok I have a table called cdd_merge_children which has a column called comments. In this column I am storing dynamic SQL such as
    SELECT EVENT_ID FROM EVENT WHERE ACCOUNT_ID = :ACCOUNT_NO
    Now in my code I retrieve this SQL statement and use it as follows:
    --get the comments from the table and execute the dynamic sql using the looser.
    OPEN col_cv FOR ls_comments USING gvloosingaccount ;
    --col_cv is a reference cursor BTW
    --dump the curosr values in the table
    FETCH col_cv BULK COLLECT INTO loosingvals ;
    Ok at this fetch is where I am getting the following error
    ORA-01001: invalid cursor
    Why ? Anyhelp would be great
    Thank's
    Sameer Handa

  • Invalid Cursor Error when executing a form

    I am getting the following error
    "Error Executing Cursor
    ORA-01001: invalid cursor"
    when I try to "Submit" information in a form based on the procedure below. What's the problem?! The procedure compiles fine.
    create or replace procedure MARKETING_FORM_2_7
    (ToAdd in Varchar2,
    FromAdd in Varchar2,
    Subject in Varchar2,
    SenderName in Varchar2,
    Branch in Varchar2,
    Phone in Varchar2,
    Address in Varchar2,
    Suggestion in Varchar2,
    SalesPromo in Varchar2,
    TradeshowPrep in Varchar2,
    SalesMaterials in Varchar2,
    DirectMail in Varchar2,
    CounterDays in Varchar2,
    BranchCustData in Varchar2,
    Other in Varchar2,
    ProjectName in Varchar2,
    Purpose in Varchar2,
    Audience in Varchar2,
    WhoPay in Varchar2,
    Deadline in Varchar2,
    Progress in Varchar2,
    EmployeeUpdate in Varchar2,
    WESCOWin in Varchar2,
    DescribeWin in Varchar2,
    PotentialValue in Varchar2,
    PartBranches in Varchar2,
    SignifPeople in Varchar2,
    SpecialFactors in Varchar2)
    is
    mailhost Varchar2(15) :='CLAPTON';
    mail_conn utl_smtp.connection;
    crlf varchar2(2):=chr( 13 )||chr( 10 );
    mesg varchar2(5000);
    begin
    mail_conn := utl_smtp.open_connection(mailhost,25);
    mesg:= 'From: <'||FromAdd||'>' ||crlf ||
    'To: '||ToAdd || crlf ||
    'Subject: '||Subject || crlf ||
    '' ||crlf||
    'Name: '||SenderName || crlf ||
    'Branch: '||Branch || crlf ||
    'Phone: '||Phone || crlf ||
    'Address: '||Address || crlf ||
    'Comment or Suggestion: ' || Suggestion || crlf ||
    'Sales Promotion Assistance: '|| SalesPromo || crlf ||
    'Tradeshow Assistance: '|| TradeshowPrep || crlf ||
    'Sales Materials or Presentations Assistance: '|| SalesMaterials || crlf ||
    'Direct Mail Assistance: '|| DirectMail || crlf ||
    'Counter Days Assistance: '|| CounterDays || crlf ||
    'Customer Database Assistance: '|| BranchCustData || crlf ||
    'Other: '|| Other || crlf ||
    'Project Name: '|| ProjectName|| crlf ||
    'Purpose: '|| Purpose || crlf ||
    'Indended Audience: '|| Audience || crlf ||
    'Who Will Pay?: ' || WhoPay || crlf ||
    'Deadline: '|| Deadline || crlf ||
    'Progress Made: ' || Progress || crlf ||
    'Mailing List Update: ' || EmployeeUpdate || crlf ||
    'WESCO Win: '|| WESCOWin || crlf ||
    'Win Description: ' || DescribeWin || crlf ||
    'Contract Value/Potential Sales: '|| PotentialValue || crlf ||
    'Participating Branches: '|| PartBranches || crlf ||
    'Significant Contributors: '|| SignifPeople || crlf ||
    'Special Factors: '|| SpecialFactors;
    utl_smtp.helo(mail_conn, mailhost);
    utl_smtp.mail(mail_conn, FromAdd);
    utl_smtp.rcpt(mail_conn, ToAdd);
    utl_smtp.data(mail_conn, mesg);
    utl_smtp.quit(mail_conn);
    end;

    Try executing the procedure independently (say from sqlplus) to see whether the procedure works fine.
    Alternatively, try commenting out the calls to the utl_smtp packages to see whether the procedure works.

  • Getting Invalid Cursor Error

    Hi, I am having trouble with my code and it is generating an error in the alert logs and trace files. Can i ask for help?
    Fri Sep 02 19:20:33 2011
    Errors in file D:\oracle\dumps\prod_ora_5312.trc:
    ORA-00600: internal error code, arguments: [17281], [1001], [0x680CAB34], [], [], [], [], []
    ORA-01001: invalid cursor
    The trace file says:
    TraceFiles:
    Oracle process number: 20
    Windows thread id: 5312, image: ORACLE.EXE (SHAD)
    *** SERVICE NAME:(PROD) 2011-09-02 10:43:22.592
    *** SESSION ID:(133.14370) 2011-09-02 10:43:22.592
    *** 2011-09-02 10:43:22.592
    ksedmp: internal or fatal error
    ORA-00600: internal error code, arguments: [17281], [1001], [0x680CAB34], [], [], [], [], []
    ORA-01001: invalid cursor
    Current SQL statement for this session:
    declare  cursor NlsParamsCursor is    SELECT FROM nls_session_parameters;begin SELECT Nvl(Lengthb(Chr(65536)), Nvl(Lengthb(Chr(256)), 1)) INTO :CharLength FROM dual; for NlsRecord in NlsParamsCursor loop if NlsRecord.parameter = 'NLS_DATE_LANGUAGE' then :NlsDateLanguage := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_DATE_FORMAT' then :NlsDateFormat := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_NUMERIC_CHARACTERS' then :NlsNumericCharacters := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_TIMESTAMP_FORMAT' then :NlsTimeStampFormat := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_TIMESTAMP_TZ_FORMAT' then :NlsTimeStampTZFormat := NlsRecord.value; end if; end loop;end;*
    What is wrong with this code and how can i resolve this? Thanks!
    Edited by: gab-gab on Sep 2, 2011 7:36 PM

    maybe (bind variables :CharLength etc. belong to SQL not PL/SQL)
    declare
      cursor NlsParamsCursor is SELECT * FROM nls_session_parameters;
      CharLength number;
      NlsDateLanguage varchar2(40);
      NlsDateFormat varchar2(40);
      NlsNumericCharacters varchar2(40);
      NlsTimeStampFormat varchar2(40);
      NlsTimeStampTZFormat varchar2(40);
    begin
      SELECT Nvl(Lengthb(Chr(65536)), Nvl(Lengthb(Chr(256)), 1))
        INTO CharLength
        FROM dual;
      for NlsRecord in NlsParamsCursor
      loop
        if NlsRecord.parameter = 'NLS_DATE_LANGUAGE' then
          NlsDateLanguage := NlsRecord.value;
        elsif NlsRecord.parameter = 'NLS_DATE_FORMAT' then
          NlsDateFormat := NlsRecord.value;
        elsif NlsRecord.parameter = 'NLS_NUMERIC_CHARACTERS' then
          NlsNumericCharacters := NlsRecord.value;
        elsif NlsRecord.parameter = 'NLS_TIMESTAMP_FORMAT' then
          NlsTimeStampFormat := NlsRecord.value;
        elsif NlsRecord.parameter = 'NLS_TIMESTAMP_TZ_FORMAT' then
          NlsTimeStampTZFormat := NlsRecord.value;
        end if;
      end loop;
    end;Regards
    Etbin
    Edited by: Etbin on 3.9.2011 8:48
    comment about probable reason of the exception raised
    Edited by: Etbin on 4.9.2011 11:58
    or you had in mind this http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/expressions012.htm#i1033659

  • Recieving ORA-01722 invalid number error while creating a materialized view

    Hi,
    I am receiving a ORA-01722 invalid number error while creating a materialized view. when run the select statement of the view i don't get any error, but when i use the same select statement to create a materialized view i receive this error. Could any please help in resolving this error. Here is the code i am using to create a materialized view.
    CREATE MATERIALIZED VIEW MV_EBS_CH_CLOSED
    REFRESH FORCE ON DEMAND
    AS
    SELECT DISTINCT kr.request_id, org.org_unit_name,
    ebs_ch_ticket_type (kr.request_id) ticket_type,
    DECODE
    (kr.status_code,
    'CLOSED_SUCCESS', kr.last_update_date,
    'IN_PROGRESS', (SELECT MAX (start_time)
    FROM ebs_ch_datastore ecd1
    WHERE kr.request_id = ecd1.request_id
    AND workflow_step_name =
    'Final BA Review and Deployment Exit Criteria')
    ) closed_date,
    substr(krhd.visible_parameter12,1,10) siebel_start_date,
    kr.creation_date itg_start_date
    FROM kcrt_requests kr,
    kcrt_request_types krt,
    kcrt_req_header_details krhd, kcrt_request_details krd1,
    (SELECT koum.user_id user_id,
    DECODE (koup.org_unit_name,
    'IT Implementations', 'CHS - Service Management BA',
    koup.org_unit_name
    ) org_unit_name
    FROM krsc_org_unit_members koum, krsc_org_units koup
    WHERE 1 = 1
    AND 'Y' = koup.enabled_flag
    AND koum.org_unit_id = koup.org_unit_id
    AND EXISTS (
    SELECT 'X'
    FROM krsc_org_units kouc
    WHERE koup.org_unit_id = kouc.org_unit_id
    START WITH kouc.parent_org_unit_id =
    ANY (SELECT org_unit_id
    FROM krsc_org_units krsc_org_units1
    WHERE 'Clearinghouse' =
    org_unit_name)
    CONNECT BY kouc.parent_org_unit_id =
    PRIOR kouc.org_unit_id)
    UNION
    SELECT kou.manager_id user_id,
    DECODE
    (kou.org_unit_name,
    'IT Implementations', 'CHS - Service Management BA',
    kou.org_unit_name
    ) org_unit_name
    FROM krsc_org_units kou
    WHERE 'Y' = kou.enabled_flag
    START WITH kou.parent_org_unit_id =
    (SELECT org_unit_id
    FROM krsc_org_units krsc_org_units2
    WHERE 'Clearinghouse' = org_unit_name)
    CONNECT BY kou.parent_org_unit_id = PRIOR kou.org_unit_id) org
    WHERE krt.request_type_id = kr.request_type_id
    AND krt.request_type_name IN ('Bug Fix', 'IT Enhancement')
    and kr.REQUEST_ID = krd1.request_id
    and krd1.batch_number = 1
    AND kr.request_id = krhd.request_id
    AND org.user_id in (krd1.parameter4, krd1.parameter5, krd1.parameter7)
    AND ( 'CLOSED_SUCCESS' = kr.status_code
    OR 'IN_PROGRESS' = kr.status_code
    AND kr.request_id IN (
    SELECT request_id
    FROM (SELECT DISTINCT request_id,
    MAX
    (start_time)
    closed_date
    FROM ebs_ch_datastore
    WHERE 'Final BA Review and Deployment Exit Criteria' =
    workflow_step_name
    GROUP BY request_id))
    Thanks,
    Shaik Mohiuddin

    This error occurs when you try to create a materialized view , but if you run the sql the results are perfectly fine. Well it happend to me also and to fix this I made sure all the coulmns have the same data type which are used in joins or in where clause.
    use
    where
    to_number(col1)=to_number(col2) and to_number(col3)=to_number(col4)
    hope this helps..

  • How to determine offending column in ORA-01722: invalid number error ...

    When an error like
    ORA-01722: invalid number error
    occurs and you are dealing with many columns that could be the 'culprit', does anyone have a method by which
    you can quickly determine offending column?

    SQL PLus will tell you:
    SQL> create table t
      2  (col1  number
      3  ,col2  number
      4  ,col3  number
      5  ,col4  number
      6  ,col5  number
      7  );
    Table created.
    SQL> create table x
      2  (col1  varchar2(10)
      3  ,col2  varchar2(10)
      4  ,col3  varchar2(10)
      5  ,col4  varchar2(10)
      6  ,col5  varchar2(10)
      7  );
    Table created.
    SQL> insert into x values ('1','2','x','4','5');
    1 row created.
    SQL> insert into t(col1,col2,col3,col4,col5)
      2  select col1,col2,col3,col4,col5 from x;
    select col1,col2,col3,col4,col5 from x
    ERROR at line 2:
    ORA-01722: invalid numberAnd if you rearrange your sql like this, sql plus will give you the line number of the offending column:
    SQL> insert into t
      2  (col1
      3  ,col2
      4  ,col3
      5  ,col4
      6  ,col5
      7  )
      8  select col1
      9        ,col2
    10        ,col3
    11        ,col4
    12        ,col5
    13  from x;
          ,col3
    ERROR at line 10:
    ORA-01722: invalid number

  • Please help: Case Statement - ORA-01722: invalid number Error

    Hi All,
    I'm trying to use Case statement to recode Cancelled statuses into two groups
    'Reject' if the difference between first date and last date is less than 29 and
    'Accept' if the difference between first date and last date is greater than 30
    Here is my 'test' data:
    STATUS     FIRST_DATE     LAST_DATE
    Transfer     10/08/2011     10/09/2011
    Mover     10/08/2011     15/09/2011
    Cancel     10/08/2011     16/09/2011
    Cancel     10/08/2011     5/09/2011
    Here is the syntax
    select a.*,
    (CASE WHEN a.STATUS ='Cancel' THEN (round(a.LAST_DATE-a.FIRST_DATE))
    ELSE 0
    END) CAN_DAYS,
    (CASE WHEN 'CAN_DAYS' >29 THEN 'Reject'
    WHEN 'CAN_DAYS' <30 THEN 'Accept'
    END) Reject_Accept
    from test a
    The first CASE statement works fine and gives me this
    STATUS     FIRST_DATE     LAST_DATE     CAN_DAYS
    Transfer     10/08/2011     10/09/2011     0
    Mover     10/08/2011     15/09/2011     0
    Cancel     10/08/2011     16/09/2011     37
    Cancel     10/08/2011     5/09/2011     26
    but the second CASE produces ORA-01722: invalid number Error. It is something to do with the CAN_DAYS data type, Oracle doesn't see it as Numeric i think.
    The result i want to see would be
    STATUS     FIRST_DATE     LAST_DATE     CAN_DAYS Reject_Accept
    Transfer     10/08/2011     10/09/2011     0
    Mover     10/08/2011     15/09/2011     0
    Cancel     10/08/2011     16/09/2011     37 Accept
    Cancel     10/08/2011     5/09/2011     26 Reject
    Could someone please help me to fix the syntax?
    Thank you in advance,

    This seems to give you your desired results...
    with test as
      ( select 'Transfer' as status, to_date('10/08/2011') as first_date, to_date('10/09/2011') as last_date  from dual union all
        select 'Mover'             , to_date('10/08/2011')              , to_date('15/09/2011')               from dual union all
        select 'Cancel'            , to_date('10/08/2011')              , to_date('16/09/2011')               from dual union all
        select 'Cancel'            , to_date('10/08/2011')              , to_date('05/09/2011')               from dual
    select  status
         ,  first_date
         ,  last_date
         ,  CAN_DAYS
         ,  CASE
              WHEN CAN_DAYS =   0 THEN NULL
              WHEN CAN_DAYS <  30 THEN 'Reject'
              WHEN CAN_DAYS >= 30 THEN 'Accept'
            END  Reject_Accept
      from  ( select  status
                   ,  first_date
                   ,  last_date
                   ,  CASE
                        WHEN STATUS ='Cancel' THEN round(LAST_DATE-FIRST_DATE)
                        ELSE 0
                      END  CAN_DAYS
                from  test
    ;

Maybe you are looking for

  • ALV Class Double click event

    Hi All, I have created an alv report using alv class. I have handled the double click event in that i am calling transaction using row currenlty selected. But after doing subtotalling the list and then i double click a line it is passing wrong data.

  • Calling a method on clicking FileDownload UI

    Hi, I need to call a method when I am clicking FileDownload UI. Please tell me if there is any possibilites. Best Wishes, Idhaya R

  • Getting the error "Error while trying to update record" when I try to force complete a plan in DAC

    Hello Everyone , I am using OBIA 7.9.3.7 . One of my execution plan has finished executing all the tasks but it is still in running mode . When I try to force complete it , it gives the error " Error while trying to update record" . Upon checking the

  • Finder keeps quiting

    I just updated my system today and after restarting the computer and all updates taking effect, when I turn on my computer Finder keeps quitting unexpectedly.  I can not do anything as the box keeps popping up with finder quiting.  What is wrong?  An

  • What shall I do with my set up and new HD?

    I just bought a new 250GB USB 7200RPM HD....finally! I have often gotten the "HD too slow" error with Logic Express. Should I just move the entire OS and all Logic Express software and components over to the new drive? Use Logic Express on the new HD