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

Similar Messages

  • 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

  • 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.

  • 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.

  • "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.

  • 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!

  • 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.

  • Payables Open Interface Purge completes with error "Invalid Cursor"

    Hello,
    I'm trying to run Payables Open Interface Purge (version 115.8) and get an invalid cursor error in the beforereport trigger. Does anyone know the cause and remedy of this? A portion of the log is below. I've looked at the cursor and everything looks fine to me.
    MSG-00001: (Import_purge 1) Check control table for the purge process
    MSG-00001: (Check_control_table 1) Lock the control table
    MSG-00003: (Check_control_table 2) Fetch import_requests
    MSG-00004: (Check_control_table 3) Check concurrent program status
    MSG-00999: FUNCTION GET_REQUEST_STATUS ERROR, Reason:
    MSG-00999: FND_CONCURRENT.GET_REQUEST_STATUS<-Check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
    MSG-00999: check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
    MSG-00999: (Import_purge 1) Check control table for the purge process
    MSG-00999: Delete record in control table..
    MSG-00999: ORA-01001: invalid cursor
    REP-1419: 'beforereport': PL/SQL program aborted.
    Thank you.

    I'm trying to run Payables Open Interface Purge (version 115.8) and get an invalid cursor error in the beforereport trigger. Does anyone know the cause and remedy of this? A portion of the log is below. I've looked at the cursor and everything looks fine to me.
    MSG-00001: (Import_purge 1) Check control table for the purge process
    MSG-00001: (Check_control_table 1) Lock the control table
    MSG-00003: (Check_control_table 2) Fetch import_requests
    MSG-00004: (Check_control_table 3) Check concurrent program status
    MSG-00999: FUNCTION GET_REQUEST_STATUS ERROR, Reason:
    MSG-00999: FND_CONCURRENT.GET_REQUEST_STATUS<-Check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
    MSG-00999: check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
    MSG-00999: (Import_purge 1) Check control table for the purge process
    MSG-00999: Delete record in control table..
    MSG-00999: ORA-01001: invalid cursor
    REP-1419: 'beforereport': PL/SQL program aborted.11i: Payables Open Interface Invoice Import Troubleshooting Guide (APXIIMPT) [ID 107628.1] -- 3. Open Interface Import Purge Fails with ORA-01001: Invalid Cursor
    Thanks,
    Hussein

  • Invalid Cursor

    From Last 4 hours I am trying to resolve below issue.
    Please Please.......Please Help me out.
    Not getting that what is the problem ???? every thing is alright, why the error is comming on different database.
    SQL*Plus: Release 10.1.0.2.0 - Production on Wed Jul 25 11:57:49 2007
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    With the Partitioning and OLAP options
    JServer Release 9.2.0.6.0 - Production
    SQL>  select * from v$version
      2  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE    9.2.0.6.0       Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    SQL>
    SQL> SELECT * FROM GLOBAL_NAME
      2  /
    GLOBAL_NAME
    PNRDPD
    SQL>
    SQL> CREATE OR REPLACE PACKAGE ORAPDEV_PKG IS
      2  PROCEDURE DUAL_DATA(P_DEPTNO IN NUMBER, RESULTSET IN OUT SYS_REFCURSOR);
      3  END ORAPDEV_PKG;
      4  /
    Package created.
    SQL>
    SQL>
    SQL>  CREATE OR REPLACE PACKAGE BODY ORAPDEV_PKG IS
      2   PROCEDURE DUAL_DATA(P_DEPTNO IN NUMBER, RESULTSET IN OUT SYS_REFCURSOR) IS
      3    BEGIN
      4    OPEN RESULTSET FOR 'SELECT EMPNO FROM SCOTT.EMP WHERE DEPTNO = '||P_DEPTNO;
      5    END;
      6   END ORAPDEV_PKG;
      7  /
    Package body created.
    SQL>
    SQL>
    SQL> VARIABLE DTA REFCURSOR;
    SQL> EXEC ORAPDEV_PKG.DUAL_DATA(10,:DTA);
    PL/SQL procedure successfully completed.
    SQL> PRINT DTA
         EMPNO
          7782
          7839
          7934
    SQL>
    SQL>
    SQL>
    SQL> GRANT EXECUTE ON ORAPDEV_PKG TO PUBLIC;
    Grant succeeded.
    SQL> New Session of Another Database
    SQL> CONNECT XXX/XXX@CISDPD
    Connected.
    SQL> create public database link PNRAPD connect to xxx identified by xxx using 'pnrapd';
    Database link created.
    SQL> SELECT COUNT(*) FROM ALL_TABLES@PNRAPD
      2  /
      COUNT(*)
           722
    SQL>
    SQL> CREATE PUBLIC SYNONYM ORAPDEV_PKG FOR ORAPDEV_PKG@PNRAPD;
    Synonym created.
    SQL>
    SQL> VARIABLE DTA REFCURSOR;
    SQL> EXEC ORAPDEV_PKG.DUAL_DATA(10,:DTA);
    BEGIN ORAPDEV_PKG.DUAL_DATA(10,:DTA); END;
    ERROR at line 1:
    ORA-01001: invalid cursor
    ORA-02063: preceding line from PNRAPD
    SQL>
    SQL>
    SQL> SELECT * FROM GLOBAL_NAME;
    GLOBAL_NAME
    CISDPD
    SQL>
    SQL> EXEC ORAPDEV_PKG.DUAL_DATA@pnrapd(10,:DTA);
    BEGIN ORAPDEV_PKG.DUAL_DATA@pnrapd(10,:DTA); END;
    ERROR at line 1:
    ORA-01001: invalid cursor
    ORA-02063: preceding line from PNRAPD
    SQL> SELECT COUNT(*) FROM ALL_TABLES@PNRAPD
      2  /
      COUNT(*)
           722
    SQL>
    SQL> select * from v$version
      2  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for Linux: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    SQL> 

    again.....:(
    how can I resolve this issue ??
    PNRAPD DATABASE
    CREATE OR REPLACE PACKAGE orapdev_pkg IS
      TYPE rcursor IS REF CURSOR;
      PROCEDURE dual_data(p_deptno  IN NUMBER
                         ,resultset IN OUT rcursor);
    END orapdev_pkg;
    CREATE OR REPLACE PACKAGE BODY orapdev_pkg IS
      PROCEDURE dual_data(p_deptno  IN NUMBER
                         ,resultset IN OUT rcursor) IS
      BEGIN
        OPEN resultset FOR 'SELECT EMPNO FROM SCOTT.EMP WHERE DEPTNO = ' || p_deptno;
      END;
    END orapdev_pkg;
    CISDPD DATABASE
    SQL> var dta ORAPDEV_PKG.RCURSOR;
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
                        VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
                        NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
                        BINARY_FLOAT | BINARY_DOUBLE ] ]
    SQL>
    SQL>
    SQL>
    SQL> declare
      2  vempno   scott.emp.empno@pnrapd%type;
      3  DTA      ORAPDEV_PKG.RCURSOR;
      4  begin
      5  ORAPDEV_PKG.DUAL_DATA(10,DTA);
      6  LOOP
      7  FETCH DTA
      8  INTO  vempno;
      9  EXIT WHEN dta%NOTFOUND;
    10  DBMS_OUTPUT.PUT_LINE(vempno);
    11  END LOOP;
    12  CLOSE dta;
    13  end;
    14  /
    declare
    ERROR at line 1:
    ORA-01001: invalid cursor
    ORA-06512: at line 7Please help.

  • INVALID CURSOR - Anonymous Block calling Cursor in function

    I am getting an error when trying to call my cursor.
    CREATE OR REPLACE PACKAGE tax_update
    AS
    TYPE gencur IS ref cursor;
    FUNCTION tax_sf
       p_state IN bb_tax.state%type,
       p_thecursor IN OUT gencur
    RETURN NUMBER;
    END;
    CREATE OR REPLACE PACKAGE BODY tax_update
    AS
    FUNCTION tax_sf
       p_state IN bb_tax.state%type,
       p_thecursor IN OUT gencur
    RETURN NUMBER
      IS
      lv_taxrate NUMBER;
    BEGIN
      OPEN p_thecursor FOR
       SELECT taxrate
       FROM bb_tax
       WHERE state = p_state;
      RETURN lv_taxrate;
    END;
    END;
    DECLARE
      tax_cur tax_update.gencur;
      rec_tax bb_tax%rowtype;
    BEGIN
    LOOP
      FETCH tax_cur INTO rec_tax;
       EXIT WHEN tax_cur%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
    END LOOP;
    END;
    DECLARE
    ERROR at line 1:
    ORA-01001: invalid cursor
    ORA-06512: at line 6Assignment is to create a package that will hold tax rates by state in a packaged cursor. The package will contain a function that can receive a 2 character state abbr. as an argument and find a match in the cursor and return the tax rate for tha tstate. An anonymous block will test the function with state of NC.
    Can anyone assist?

    You would need to call the function to open the cursor before you try to fetch from the cursor
    DECLARE
      tax_cur tax_update.gencur;
      rec_tax bb_tax%rowtype;
      l_some_number number;
    BEGIN
      l_some_number :=  tax_update.tax_sf( <<some state parameter>>, tax_cur );
      LOOP
        FETCH tax_cur INTO rec_tax;
        EXIT WHEN tax_cur%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
      END LOOP;
    END;A couple of points, though.
    1) Your function returns a NUMBER but that NUMBER will always be NULL. It seems rather unlikely that this is really what you want. It would seem to make more sense for the function to return the cursor rather than returning a superfluous number.
    2) Your function requires a `bb_tax.state%type` parameter. But your anonymous block doesn't seem to have any concept of a state so I'm not sure what you want to pass in there.
    3) Looking at the code, it seems a bit odd that your cursor returns a single column of data. If a state can have multiple rates, wouldn't you need to select some additional criteria in order to figure out which sort of tax each row represents or to otherwise differentiate different rows? If a state can only have a single tax rate, it makes no sense to open a cursor that is only going to ever return a single row.
    4) There is no need to declare your own weak ref cursor type (tax_update.gencur). You can just use the Oracle built-in type SYS_REFCURSOR.
    Justin

  • Invalid Cursor, Please HEPL ME!!!!!!!

    I see the following error:
    ERROR at line 1:ORA-01001: invalid cursor
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 824ORA-06512: at "SYS.DBMS_SQL", line 32
    ORA-06512: at "IWF_ADMIN.SP_ESTADISTICAS", line 38ORA-06512: at line 2
    with the following code:
    create or replace procedure SP_ESTADISTICASisc_idsite number;c_hora number;
    c_dia number;c_fail number:=0;c_incomple number:=0;c_comple number:=0;
    c_qnc number:=0;c_wap number:=0;c_fax number:=0;sumbusy number:=0;
    c_busy number:=0;sumtime number:=0;sumin number:=0;sumout number:=0;
    fechai date;Temp varchar2(20);fechac varchar2(20);--fechac date;
    fechaf date;--cursor cursor_est return (idsite tablecall.idsite%typefecha
    tablecall.fecha%type, bytein tablecall.bytein%type, typecall
    tablecall.typecall%type, num_busych tablecall.num_busych%type, tiempoconec
    tablecall.tiempoconec%type);cursor_est tablecall2%ROWTYPE;fdbk INTEGER;
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;v_select varchar2(200);begin
    select concat(to_char(min(fecha),'dd/mm/yyyy'),' ') into Temp from tablecall2;
    for cur_idsite in (select distinct(idsite) as idsite from tablecall2) loop
    for c_dia in 0..31 loop fechai:=to_date(Temp,'dd/mm/yyyy');
    fechai:=fechai + c_dia; for c_hora in 0..23 loop
    -- fechac:=to_date(Temp&#0124; &#0124;to_char(c_hora,'fm09')&#0124; &#0124;':00:00');
    fechac:=Temp&#0124; &#0124;to_char(c_hora,'fm09');
    -- fechaf:=to_date(Temp&#0124; &#0124;to_char(c_hora,'fm09')&#0124; &#0124;':59:59');
    v_select:='select idsite,fecha,bytein,typecall,num_busych,tiempoconec
    from tablecall2 where idsite ='&#0124; &#0124;to_char(cur_idsite.idsite,'fm0999')&#0124; &#0124;' and
    to_char(fecha,'&#0124; &#0124;chr(39)&#0124; &#0124;'dd/mm/yyyy hh24:mi:ss'&#0124; &#0124;chr(39)&#0124; &#0124;') like
    '&#0124; &#0124;chr(39)&#0124; &#0124;fechac&#0124; &#0124;'%'&#0124; &#0124;chr(39);
    DBMS_SQL.PARSE(cur,v_select,DBMS_SQL.NATIVE);
    DBMS_SQL.DEFINE_COLUMN(cur, 1, 1);
    DBMS_SQL.DEFINE_COLUMN(cur, 2, sysdate);
    DBMS_SQL.DEFINE_COLUMN(cur, 3, 1); DBMS_SQL.DEFINE_COLUMN(cur, 4, 1);
    DBMS_SQL.DEFINE_COLUMN(cur, 5, 1); DBMS_SQL.DEFINE_COLUMN(cur, 6, 1);
    fdbk := DBMS_SQL.EXECUTE(cur); LOOP
    EXIT WHEN DBMS_SQL.FETCH_ROWS(cur) = 0;
    DBMS_SQL.COLUMN_VALUE(cur,1,cursor_est.idsite);
    DBMS_SQL.COLUMN_VALUE(cur,2,cursor_est.fecha);
    DBMS_SQL.COLUMN_VALUE(cur,3,cursor_est.bytein);
    DBMS_SQL.COLUMN_VALUE(cur,4,cursor_est.typecall);
    DBMS_SQL.COLUMN_VALUE(cur,5,cursor_est.num_busych);
    DBMS_SQL.COLUMN_VALUE(cur,6,cursor_est.tiempoconec);
    if cursor_est.bytein=0 then c_fail:=c_fail+1; end if;
    if cursor_est.bytein<125 then c_incomple:=c_incomple+1; end if;
    if cursor_est.bytein>125 then c_comple:=c_comple+1; end if;
    if cursor_est.typecall=2 then c_fax:=c_fax+1; end if;
    if cursor_est.typecall=1 then c_qnc:=c_qnc+1; end if;
    if cursor_est.typecall=0 then c_wap:=c_wap+1; end if; c_busy:=c_busy+1;
    sumbusy:=cursor_est.num_busych + sumbusy;
    sumtime:=cursor_est.tiempoconec + sumtime; sumin:=cursor_est.bytein + sumin;
    sumout:=cursor_est.byteout + sumout; END LOOP; if c_busy<>0 then
    sumbusy:=sumbusy/c_busy; else sumbusy:=0; end if;
    execute immediate 'insert into tableest
    values('&#0124; &#0124;to_char(cur_idsite.idsite,'fm0999')&#0124; &#0124;',
    to_date(concat('&#0124; &#0124;chr(39)&#0124; &#0124;fechac&#0124; &#0124;chr(39)&#0124; &#0124;','&#0124; &#0124;chr(39)&#0124; &#0124;':00:00'&#0124; &#0124;chr(39)&#0124; &#0124;'),'&#0124; &#0124;chr(39)&#0124; &#0124;'dd/mm/yyyy
    HH24:mi:ss'&#0124; &#0124;chr(39)&#0124; &#0124;'),'&#0124; &#0124;to_char(c_fail,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(c_incomple,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(c_comple,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(c_wap,'fm0999999999')&#0124; &#0124;','| |to_char(c_qnc,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(c_fax,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(sumbusy,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(sumtime,'fm0999999999')&#0124; &#0124;','&#0124; &#0124;to_char(su min,'fm0999999999')&#0124; &#0124; ','&#0124; &#0124;to_char(sumout,'fm0999999999')&#0124; &#0124;')';
    commit; execute immediate 'delete from tablecall2 where
    idsite='&#0124; &#0124;to_char(cur_idsite.idsite,'fm0999')&#0124; &#0124;' and
    to_char(fecha,'&#0124; &#0124;chr(39)&#0124; &#0124;'dd/mm/yyyy HH24:mi:ss'&#0124; &#0124;chr(39)&#0124; &#0124;') like
    '&#0124; &#0124;chr(39)&#0124; &#0124;fechac&#0124; &#0124;'%'&#0124; &#0124;chr(39);-- commit;
    DBMS_SQL.CLOSE_CURSOR (cur); end loop; end loop;end loop;
    end;
    what is happening it?, how can to resolve it?
    Thank by any idea.
    null

    It is very difficult to read. However, the previous reply is correct you have closed the cursor inside the loop.
    Also, hoping you will take this as a suggestion, I have modified the proc to utilize 8i features and get rid of the DBMS_SQL utility (to much coding) and the CHR(39)
    I would have written this in spanish but my ability to write in spanish is shamefull, but
    BUENA SUERTE CON TU PROJECTO.
    create or replace procedure SP_ESTADISTIC AS
    c_dia number;
    c_fail number:=0;
    c_incomple number:=0;
    c_comple number:=0;
    c_qnc number:=0;
    c_wap number:=0;
    c_fax number:=0;
    c_busy number:=0;
    sumbusy number:=0;
    sumtime number:=0;
    sumin number:=0;
    sumout number:=0;
    fechai date;
    Temp varchar2(20);
    fechac varchar2(20);
    TYPE REF_CUR IS REF CURSOR ;
    CV REF_CUR ;
    v_sql_stmt varchar2(2000);
    TYPE CUR_REC IS RECORD
    (idsite tablecall.idsite%type,
    fecha tablecall.fecha%type,
    bytein tablecall.bytein%type,
    typecall tablecall.typecall%type,
    num_busych tablecall.num_busych%type,
    tiempoconec tablecall.tiempoconec%type);
    CUR_DATA CUR_REC ;
    BEGIN
    select concat(to_char(min(fecha),'dd/mm/yyyy'),' ') into Temp from tablecall2;
    for cur_idsite in (select distinct(idsite) as idsite from tablecall2) loop
    for c_dia in 0..31 loop
    fechai:=to_date(Temp,'dd/mm/yyyy');
    fechai:=fechai + c_dia;
    for c_hora in 0..23 loop
    fechac := Temp&#0124; &#0124;to_char(c_hora,'fm09');
    V_SQL_STMT :='select idsite, fecha, bytein, typecall, num_busych, tiempoconec '&#0124; &#0124;
    ' from tablecall2 where idsite = '&#0124; &#0124;
    to_char(cur_idsite.idsite, 'fm0999') &#0124; &#0124;
    ' and to_char(fecha, ''dd/mm/yyyy hh24:mi:ss'' ) '&#0124; &#0124;
    ' like '''&#0124; &#0124; fechac &#0124; &#0124; '%'' ';
    OPEN CV FOR v_sql_stmt ;
    LOOP
    FETCH CV INTO CUR_DATA ;
    EXIT WHEN CV%NOTFOUND;
    if CUR_DATA.bytein=0 then c_fail:=c_fail+1; end if;
    if CUR_DATA.bytein<125 then c_incomple:=c_incomple+1; end if;
    if CUR_DATA.bytein>125 then c_comple:=c_comple+1; end if;
    if CUR_DATA.typecall=2 then c_fax:=c_fax+1; end if;
    if CUR_DATA.typecall=1 then c_qnc:=c_qnc+1; end if;
    if CUR_DATA.typecall=0 then c_wap:=c_wap+1; end if;
    c_busy:=c_busy+1;
    sumbusy := CUR_DATA.num_busych + sumbusy;
    sumtime := CUR_DATA.tiempoconec + sumtime;
    sumin := CUR_DATA.bytein + sumin;
    -- sumout:=CUR_DATA.byteout + sumout;
    END LOOP;
    if c_busy<>0 then
    sumbusy:=sumbusy/c_busy;
    else
    sumbusy:=0;
    end if;
    v_sql_stmt := 'insert into tableest '&#0124; &#0124;
    ' values(:1, :2, :3, :4, :5, :6, '&#0124; &#0124;
    ':7, :8, :9, :10, :11, :12 ) ' ;
    execute immediate v_sql_stmt using
    to_char(CUR_DATA.idsite,'fm0999'),
    to_date(fechac&#0124; &#0124;':00:00', 'dd/mm/yyyyHH24:mi:ss'),
    to_char(c_fail, 'fm0999999999'),
    to_char(c_incomple,'fm0999999999'),
    to_char(c_comple, 'fm0999999999'),
    to_char(c_wap, 'fm0999999999'),
    to_char(c_qnc, 'fm0999999999'),
    to_char(c_fax, 'fm0999999999'),
    to_char(sumbusy, 'fm0999999999'),
    to_char(sumtime, 'fm0999999999'),
    to_char(sumin, 'fm0999999999') ,
    to_char(sumout, 'fm0999999999') ;
    execute immediate
    'delete from tablecall2 where idsite='
    &#0124; &#0124;to_char(cur_idsite.idsite,'fm0999')
    &#0124; &#0124;' and to_char(fecha,''dd/mm/yyyy HH24:mi:ss'' ) '
    &#0124; &#0124;' like '''&#0124; &#0124; fechac &#0124; &#0124; '%'' ';
    commit;
    end loop;
    close CV;
    end loop;
    end loop;
    end;

  • "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.

  • ORA-01001 error while TSPITR

    I keep on getting ORA-01001 : invalid cursor error while trying to transport a tablespace as a part of TSPITR.
    Here is how it looks:
    ===================================================
    C:\>exp parfile=c:\exp_transport.par
    Export: Release 9.2.0.1.0 - Production on Tue Apr 27 14:47:19 2004
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    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 819
    ORA-06512: at "SYS.DBMS_SQL", line 19
    ORA-06512: at "SYS.DBMS_TTS", line 774
    ORA-25153: Temporary Tablespace is Empty
    ORA-06512: at "SYS.DBMS_PLUGTS", line 1093
    ORA-06512: at line 1
    EXP-00000: Export terminated unsuccessfully
    ===================================================
    Any suggestion ?

    Guys,
    Come on Give me a Solution.
    Badly Needed....

  • 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.

  • Invalid cursor in Oracle 9i (but works on 11g)

    Hi,
    I have the function:
    function get_capat_transa(p1 sys_refcursor, p2 number) return varchar2 is
      cod varchar2(40);
    begin
      for i in 1..p2 loop
        fetch p1 into cod;
      end loop;
      return cod;
    end;Ok, when i call this function in 11g like:
    select get_capat_transa( osapi_ni.getCapatTransa('0373',100, 23453425), 1 ) cod
    from dual
    The first parameter supplied is osapi_ni.getCapatTransa('0373',100, 23453425), another function within a package, which returns a ref_cursor.
    This works with no errors in Oracle 11g.
    The same select written in Oracle 9i generates the error:
    ORA-01001: invalid cursor
    I pressed Yes to view the stack error and i got that the error raises from the line 'fetch p1 into cod'.
    Any workaround for this, to work in 9i also?
    Thanks!
    Edited by: Roger22 on 18.08.2011 09:02
    Edited by: Roger22 on 18.08.2011 09:03

    Hi, It did not helped me..
    More simply (so a simplest example) - you can try in 9i:
    create or replace function getCapatTransa2 return sys_Refcursor is
       tmp sys_Refcursor;
       error varchar2(1500);
    begin
        open tmp for select 'x' from dual;
        return tmp;
    end getCapatTransa2;then
    create or replace function get_capat_transa(p1 sys_refcursor, p2 number) return varchar2 is
      cod varchar2(40);
    begin
      for i in 1..p2 loop
    --    if p1%isopen then
          --raise_application_error (-20667, cod);
          fetch p1 into cod;
      end loop;
      return cod;
    end;and finally:
    select get_capat_transa(getCapatTransa2, 1 ) cod
      from dualWhy in 9i returns invalid cursor and in 11 returns 'x' ? Seems like in 9i the cursor p1 is not open, but why? i can't explain..
    Edited by: Roger22 on 18.08.2011 10:43

Maybe you are looking for

  • Taking a filename in a 'file' field for upload..

    What I'm ideally trying to achieve here is to have a 'file' field in an insert record page, where I can select a file, and upload it to a folder on the server. I've sorted that part on it's own at least. But there also needs to be a text field, eg 'F

  • How do I connect other devices wirelessly?

    My imac can connect to the internet wirelessly (no problems) but now I'm trying to connect a Pandigital tablet and an RCA wi-fi streaming media player to my internet network. My network isn't showing up on the available networks. What am i doing wron

  • Connecting zen microphoto to home ste

    Does anyone know of a device to connect the zen microphoto to their home stereo? I found a device to be able to play my zen in my car, but how can I connect it to my stereo? I have an okay amount of music on there, but I am hesitant about adding more

  • HT204406 Playlist missing

    ONE playlist doesn't appear on my iPhone via iTunes Match/iCloud. ALL music is "checked" to be available but that one playlist doesn't appear. It DOES appear on my iPad. What gives?

  • NI-DAQ PCI-6023E nt embedded component

    Hi all I am trying to develop a KDF component for a ni-daq pci-6023e card and when I create the registy some keys stay in the CurrentControlSet instead of being related to ControlSet001. Can anyone help me??? Is there a solution to this problem or a