ERROR ORA-01002 ??????

Hi! sorry by my English......
I have this Package:
CREATE OR REPLACE PACKAGE PCK_KK
AS
TYPE CURBATCH IS REF CURSOR;
PROCEDURE PROC_SUBKK
     BATCH_SEG     OUT CURBATCH,
     BATCH_PES     OUT CURBATCH,
     NUMERROR$     OUT NUMBER,
     MSJERROR$     OUT VARCHAR2
END PCK_KK;
CREATE OR REPLACE PACKAGE BODY PCK_KK
AS
PROCEDURE PROC_SUBKK
     BATCH_SEG     OUT CURBATCH,
     BATCH_PES     OUT CURBATCH,
     NUMERROR$     OUT NUMBER,
     MSJERROR$     OUT VARCHAR2
IS
BEGIN
BEGIN
          OPEN BATCH_SEG FOR
               SELECT
                    CODIGO_SEG,
                    NOMBRE_SEG
               FROM
                    PESQUERIAS.SEGUIMIENTO@TI_PESQUERIA.US.ORACLE.COM
               ORDER BY
                    NOMBRE_SEG;
          OPEN BATCH_PES FOR
               SELECT
                    SEGUIMIENTO.CODIGO_SEG,
                    PESQUERIA.COD_PESQUERIA,
                    PESQUERIA.NOMBRE_PESQUERIA
               FROM
                    PESQUERIAS.PESQUERIA@TI_PESQUERIA.US.ORACLE.COM INNER JOIN
                    (PESQUERIAS.SEGUIMIENTO@TI_PESQUERIA.US.ORACLE.COM INNER JOIN
                    PESQUERIAS.SEGUIMIENTO_PESQUERIA@TI_PESQUERIA.US.ORACLE.COM
                    ON SEGUIMIENTO.CODIGO_SEG = SEGUIMIENTO_PESQUERIA.COD_SEG)
                    ON PESQUERIA.COD_PESQUERIA = SEGUIMIENTO_PESQUERIA.COD_PES
               ORDER BY
                    SEGUIMIENTO.CODIGO_SEG,
                    PESQUERIA.COD_PESQUERIA;
          NUMERROR$ := 0;
          MSJERROR$ := '';
          RETURN;
          EXCEPTION
               WHEN OTHERS THEN
               NUMERROR$ := SQLCODE;     
               CASE NUMERROR$
                    WHEN 100 THEN MSJERROR$:='bla bla bla';
                    WHEN -1 THEN MSJERROR$:='other bal bla bla';
                    ELSE MSJERROR$:= 'ERROR [PCK_KK] '||to_char(SQLERRM);
               END CASE;
     END;
END PROC_SUBKK;
END PCK_KK;
Ok, I execute by SqlPlus and ok!!!!!
but, by PHP so:
Warning: ocifetchstatement(): OCIFetchStatement:
ORA-01002: recuperación fuera de secuencia
in /ifop/ti/P_center_ingresar.php on line 72
And my source php is:
$Coneccion = OCILogon($User, $Passwd, $HostOracle);
$Cursor = OCINewCursor($Coneccion);
$sTmpSql = OCIParse($Coneccion,"BEGIN PROC_SUBKK.PCK_KK(:rTmp1,:rTmp2,:lNumError,:sMsjError); END;");
OCIBindByName($sTmpSql,":rTmp1",&$Cursor,-1,OCI_B_CURSOR);
OCIBindByName($sTmpSql,":rTmp2",&$Cursor,-1,OCI_B_CURSOR);
OCIBindByName($sTmpSql,":lNumError",&$lNumError,32);
OCIBindByName($sTmpSql,":sMsjError",&$sMsjError,32);
ociexecute($sTmpSql);
ociexecute($Cursor);
if ($lNumError == 0)
     $rTmp1_RecordCount = OCIfetchstatement($Cursor,&$rTmp1);
     if ($rTmp1_RecordCount > 0)
          for ($lTmp1 = 0; $lTmp1 < $rTmp1_RecordCount; $lTmp1++ )
               $aTmp1[$lTmp1][1] = $rTmp1["CODIGO_SEG"][$lTmp1];
               $aTmp1[$lTmp1][2] = $rTmp1["NOMBRE_SEG"][$lTmp1];
     $rTmp2_RecordCount = OCIfetchstatement($Cursor,&$rTmp2); <--- ERROR!!!!!! ??????
     if ($rTmp2_RecordCount > 0)
          //Si viene registros, traspasa a arreglo
          for ($lTmp1 = 0; $lTmp1 < $rTmp2_RecordCount; $lTmp1++ )
               $aTmp2[$lTmp1][1] = $rTmp1["CODIGO_SEG"][$lTmp1];
               $aTmp2[$lTmp1][2] = $rTmp1["COD_PESQUERIA"][$lTmp1];
               $aTmp2[$lTmp1][3] = $rTmp1["NOMBRE_PESQUERIA"][$lTmp1];
     OCIFreeStatement($sTmpSql);
     OCIFreeCursor($Cursor);
     OCILogoff($Coneccion);
else
     OCIFreeStatement($sTmpSql);
     OCIFreeCursor($Cursor);
     OCILogoff($Coneccion);
HELPME PLEASE
THANKS !!!!
My configuration !!!!
Web Server//
RedHat Advanced Server 2.1
Oracle Application Server 10g
Php 5
DB Server//
RedHat Advanced Server 2.1
Oracle 9i
THANKS AGAIN !!!!

Dear CJJ:
I proved subject "$cursor1 and $cursor2, for the two ref cursor parameters" and I work myself perfectly...thank you very much !!!!
          $Cursor1 = OCINewCursor($Coneccion);
          $Cursor2 = OCINewCursor($Coneccion);
          $sTmpSql = OCIParse($Coneccion,"BEGIN TI_SEL001SEGUIMIENTOPESQUERIA.SEL001SEGUIMIENTOPESQUERIA(:rTmp1,:rTmp2,:lNumError,:sMsjError); END;");
          OCIBindByName($sTmpSql,":rTmp1",&$Cursor1,-1,OCI_B_CURSOR);
          OCIBindByName($sTmpSql,":rTmp2",&$Cursor2,-1,OCI_B_CURSOR);
          OCIBindByName($sTmpSql,":lNumError",&$lNumError,32);
          OCIBindByName($sTmpSql,":sMsjError",&$sMsjError,32);
          ociexecute($sTmpSql);
          ociexecute($Cursor1);
          ociexecute($Cursor2);
I work without problems
THANKS !!!!!!

Similar Messages

  • Error ORA-01002: fetch out of sequence

    Hi all,
    I created 3 cursors. The scenario is like following :
    Begin Cur A
    Begin FOR xx IN Cur B LOOP
    Begin FOR xx IN Cur C LOOP
    End LOOP Cur C;
    commit;
    End LOOP Cur B;
    End Cur A;
    When i run the program its display error ORA-01002: fetch out of sequence.
    The objective of my program is to insert into table and commit every transaction.
    Kindly share info with me why this error happened.
    TQ.
    tim

    Tim,
    Refer to the following:
    ORA-01002: fetch out of sequence
    Cause: This error means that a fetch has been attempted from a cursor which is no longer valid.
    Note that a PL/SQL cursor loop implicitly does fetches, and thus may also cause this error. There are a number of possible causes for this error, including:
    1) Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned.
    2) If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error.
    3) Rebinding any placeholders in the SQL statement, then issuing a fetch before reexecuting the statement.
    Action:
    1) Do not issue a fetch statement after the last row has been retrieved - there are no more rows to fetch.
    2) Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE.
    3) Reexecute the statement after rebinding, then attempt to fetch again.
    HTH,
    Thierry
    Edited by: Thierry H. on May 4, 2011 12:30 PM Reformatting

  • ERROR (ORA-01002)  when Ioading a table by UPDATE/INSERT

    I get the error message ORA-01002 ( Fetch out of sequence ) when I am loading a table by UPDATE/INSERT.
    At de Runtime Audit Viewer the process of loading update a number of register, in that case 44.050 and to the left register I get the error message that I show above.

    Can you please give us some details about your source and targets. I have used UPDATE/INSERT but I did not get this kind of error.
    rgds
    -AP

  • Autonomous Transactions & error ORA-01002

    Either there's a bug w/ Autonomous Transactions or the documentation is incomplete because the AT is not working when
    called from within Cursor Loop.
    here's the outline:
    CURSOR acct_cur IS ...FOR UPDATE OF a.account_nm...
    FOR acct_rec IN acct_cur LOOP
    fis_rte_util.print_msg (...) ---autonomous transaction writes to a logging table
    ---w/ commit
    UPDATE ca_account_t
    SET account_nm = acct_rec.account_nm....
    this update statement causes a ORA-01002: fetch out of sequence exception. if
    i comment out the print_msg line it works just fine. its as if the commit in the
    AT is causing the problem. according to the documention, there should be no
    interference between these 2 blocks.
    thanks for any info or insight,
    swg
    null

    Tim,
    Refer to the following:
    ORA-01002: fetch out of sequence
    Cause: This error means that a fetch has been attempted from a cursor which is no longer valid.
    Note that a PL/SQL cursor loop implicitly does fetches, and thus may also cause this error. There are a number of possible causes for this error, including:
    1) Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned.
    2) If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error.
    3) Rebinding any placeholders in the SQL statement, then issuing a fetch before reexecuting the statement.
    Action:
    1) Do not issue a fetch statement after the last row has been retrieved - there are no more rows to fetch.
    2) Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE.
    3) Reexecute the statement after rebinding, then attempt to fetch again.
    HTH,
    Thierry
    Edited by: Thierry H. on May 4, 2011 12:30 PM Reformatting

  • WLS 5.1 to 6.1 porting issue: RequiresNew & ORA-01002 error

    Repost from the EJB group
    Environment:
    WLS 6.1.2 on WINNT w/SP6a
    java: 1.3.1 that ships with WLS 6.1
    DB: Oracle 8.1.6 (using TRANSACTION_READ_COMMITTED exclusively)
    I'm currently upgrading our application from 5.1 (ejb 1.1) to
    6.1 (ejb 2.0). I've also consolidated our 55 separate ejb jars
    into a single jar (with all 55 ejbs). Because of 1.1 entity bean
    issues, currently all our ejbs are SessionBeans. Everything works
    under 5.1 with our test Oracle instance, the 6.1 test environment
    is using the same database instance.
    I'm seeing several problems.
    Here's #1
    With the same TCUSecurityDataAccessSessionBean::updateIfNeeded
    source code and same database instance. 5.1 updates correctly,
    6.1 throws this SQLException. So, I figure its got to be a WLS 6.1 issue or
    my configuration. - I alway suspect me ;)
    ERROR - ORA-01002: fetch out of sequence
    (com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAccessSessionB
    ean_ridhfi_Impl::updateIfNeeded)
    java.sql.SQLException: ORA-01002: fetch out of sequence
    This method should be configured with transaction context of: RequiresNew
    Has the 6.1 handling of RequiresNew changed that radically?
    I'm looking for suggestions on how to debug this further.
    TIA
    Gordon
    ------------- ejb-jar.xml (edited) ------------------------
    <ejb-jar>
    <small-icon>images/green-cube.gif</small-icon>
    <enterprise-beans>
    <!-- TCUSecurityDataAccessSession -->
    <session>
    <small-icon>images/orange-cube.gif</small-icon>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <home>com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAccessSes
    sionHome</home>
    <remote>com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAccessS
    ession</remote>
    <ejb-class>com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAcce
    ssSessionBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    <assembly-descriptor>
    <method-permission>
    <description></description>
    <role-name>****</role-name> <!-- deleted for security -->
    <method>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <method-name>*</method-name>
    </method>
    </method-permission>
    <!-- TCUSecurityDataAccessSession -->
    <container-transaction>
    <method>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <method-name>updateIfNeeded</method-name>
    </method>
    <trans-attribute>RequiresNew</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <method-name>peek</method-name>
    </method>
    <trans-attribute>Supports</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    ------------- weblogic-ejb-jar.xml (uninteresting) ------------------------
    ------------- config.xml (edited) ------------------------
    <JDBCConnectionPool CapacityIncrement="5"
    DriverName="oracle.jdbc.driver.OracleDriver"
    InitialCapacity="10" MaxCapacity="100" Name="d2Pool"
    Password="*****
    Properties="user=d2engine;STATEMENT_CACHE_SIZE=200"
    Targets="myserver" URL="jdbc:oracle:thin:@*****"/>
    <JDBCTxDataSource JNDIName="jdbc/d2Pool" Name="jdbc/d2Pool"
    PoolName="d2Pool" Targets="myserver"/>
    ORA-01002 fetch out of sequence
    Cause: In a host language program, a FETCH call was issued out of sequence.
    A successful parse-and-execute call must be issued before a fetch.
    This can occur if an attempt was made to FETCH from an active set after
    all records have been fetched.
    This may be caused by fetching from a SELECT FOR UPDATE cursor after a
    commit.
    A PL/SQL cursor loop implicitly does fetches and may also cause this error.
    Action: Parse and execute a SQL statement before attempting to fetch the
    data.

    Solved.
    The 8.1.6 driver wasn't the problem.
    It turned out that our ConnectionPool utility class wasn't configured
    properly
    and when I thought that I was going TxDatasource, I was actually only
    getting
    a straight Connection. No Tx, so Oracle didn't have one open for the "FOR
    UPDATE"
    clause. Now if someone could help on my classloader question in the EJB
    group ;)
    - Gordon
    "Slava Imeshev" <[email protected]> wrote in message
    news:[email protected]...
    Gordon,
    Oracle 8.1.6 driver proved to be buggy and unstable.
    Can you update your oracle thin driver to the newest
    one? It's available from the otn.oracle.com.
    Could you also post the questionable code here, especially
    in the part related to obtaining connection, executing
    stataments, fetching results and obtaining TXs, if any?
    Regards,
    Slava Imeshev
    "Gordon Twaddell" <[email protected]> wrote in message
    news:[email protected]...
    Sree,
    I didn't mention that I'm using the Oracle thin JDBC driver
    (8.1.6.1)
    and its in the CLASSPATH.
    Slava,
    I tried the stmt.setFetchSize(). I got the same result.
    Gordon
    "Sree Bodapati" <[email protected]> wrote in message
    news:[email protected]...
    Hi Gordon,
    One possibility is the environment variable PATH might be pointing to
    an
    older version of the library files for the WebLogic jDriver forOracle.
    Check if the PATH is set to point to the right weblogicoci37.dll (inthe
    <WL_HOME for 6.1>\bin\oci817_8) and make sure your oracle_home is setto
    point to the right folders as well.
    hth
    sree
    "Gordon Twaddell" <[email protected]> wrote in message
    news:[email protected]...
    Repost from the EJB group
    Environment:
    WLS 6.1.2 on WINNT w/SP6a
    java: 1.3.1 that ships with WLS 6.1
    DB: Oracle 8.1.6 (using TRANSACTION_READ_COMMITTED exclusively)
    I'm currently upgrading our application from 5.1 (ejb 1.1) to
    6.1 (ejb 2.0). I've also consolidated our 55 separate ejb jars
    into a single jar (with all 55 ejbs). Because of 1.1 entity bean
    issues, currently all our ejbs are SessionBeans. Everything works
    under 5.1 with our test Oracle instance, the 6.1 test environment
    is using the same database instance.
    I'm seeing several problems.
    Here's #1
    With the same TCUSecurityDataAccessSessionBean::updateIfNeeded
    source code and same database instance. 5.1 updates correctly,
    6.1 throws this SQLException. So, I figure its got to be a WLS 6.1
    issue
    or
    my configuration. - I alway suspect me ;)
    ERROR - ORA-01002: fetch out of sequence
    (com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAccessSessionB
    ean_ridhfi_Impl::updateIfNeeded)
    java.sql.SQLException: ORA-01002: fetch out of sequence
    This method should be configured with transaction context of:RequiresNew
    Has the 6.1 handling of RequiresNew changed that radically?
    I'm looking for suggestions on how to debug this further.
    TIA
    Gordon
    ------------- ejb-jar.xml (edited) ------------------------
    <ejb-jar>
    <small-icon>images/green-cube.gif</small-icon>
    <enterprise-beans>
    <!-- TCUSecurityDataAccessSession -->
    <session>
    <small-icon>images/orange-cube.gif</small-icon>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <home>com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAccessSes
    sionHome</home>
    <remote>com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAccessS
    ession</remote>
    <ejb-class>com.eoriginal.engine.core.session.basicAccess.TCUSecurityDataAcce
    ssSessionBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    <assembly-descriptor>
    <method-permission>
    <description></description>
    <role-name>****</role-name> <!-- deleted for security -->
    <method>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <method-name>*</method-name>
    </method>
    </method-permission>
    <!-- TCUSecurityDataAccessSession -->
    <container-transaction>
    <method>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <method-name>updateIfNeeded</method-name>
    </method>
    <trans-attribute>RequiresNew</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>TCUSecurityDataAccessSession</ejb-name>
    <method-name>peek</method-name>
    </method>
    <trans-attribute>Supports</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    ------------- weblogic-ejb-jar.xml(uninteresting) ------------------------
    ------------- config.xml (edited) ------------------------
    <JDBCConnectionPool CapacityIncrement="5"
    DriverName="oracle.jdbc.driver.OracleDriver"
    InitialCapacity="10" MaxCapacity="100" Name="d2Pool"
    Password="*****
    Properties="user=d2engine;STATEMENT_CACHE_SIZE=200"
    Targets="myserver" URL="jdbc:oracle:thin:@*****"/>
    <JDBCTxDataSource JNDIName="jdbc/d2Pool" Name="jdbc/d2Pool"
    PoolName="d2Pool" Targets="myserver"/>
    ORA-01002 fetch out of sequence
    Cause: In a host language program, a FETCH call was issued out ofsequence.
    A successful parse-and-execute call must be issued before a fetch.
    This can occur if an attempt was made to FETCH from an active set
    after
    all records have been fetched.
    This may be caused by fetching from a SELECT FOR UPDATE cursor
    after
    a
    commit.
    A PL/SQL cursor loop implicitly does fetches and may also cause
    this
    error.
    Action: Parse and execute a SQL statement before attempting to fetch
    the
    data.

  • Error on mapping: ORA-01002

    Hi all,
    When i try to insert data from an Informix database into Oracle the mapping crashes with the error ora-01002 after 50 rows (the number of rows has some relation to Bulk Size, because when it grows the error occurs in a later row).
    I can insert the data into the table using the same connection that OWB using SQL*Plus.
    what can be the problem?
    I'm using OWB 9.2.
    thanks,
    Vitor

    Hi,
    The error that i've got on Runtime Audit Browser is "ORA-01002: fetch out of sequence ORA-02063: preceding line HSODBC@CON_STAGING_TO_INFORMIX". (HSODBC@CON_STAGING_TO_INFORMIX is the DB Link Created by OWB)
    Answering to Mahesh, no, i can't use the Loading Type "INSERT/UPDATE" on the same table, because the fields are not the same, the INSERT has more fields then UPDATE.
    Thanks,
    Vitor

  • ORA-01002: fetch out of sequence error

    Hello friends,
    I m facing a prob using a cursor for update.
    here is a piece of code:
    DECLARE
                   CURSOR c_tot_inv_qty (p_prd_id tr_periods.period_id%TYPE) IS
    SELECT total_inv_qty, item_id, period_id, dc_id
    FROM inv_dc_tmp
    WHERE period_id = p_prd_id + 1
    FOR UPDATE OF total_inv_qty;
    BEGIN
              FOR pd IN (     SELECT period_id
                             FROM tr_periods
                             WHERE status_flag = 1
                             AND period_id >= 46
    LOOP
                   FOR t_tot_inv_qty IN c_tot_inv_qty(pd.period_id) LOOP
                        BEGIN
    SELECT inv_forecast_qty
    INTO l_inv_fc_qty
    FROM inv_dc_tmp
    WHERE item_id = t_tot_inv_qty.item_id
    AND period_id = pd.period_id
    AND dc_id = t_tot_inv_qty.dc_id;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                                  l_inv_fc_qty := 0;
                        END;
    UPDATE inv_dc_tmp
    SET total_inv_qty = l_inv_fc_qty
    WHERE CURRENT OF c_tot_inv_qty;
                   END LOOP;
              END LOOP;
              COMMIT;
    END;
    i have written commit after the loop..but still it raise an error ORA-01002: fetch out of sequence
    i m unable to find out the soln
    i need ur help.
    Thanks
    RSD

    I'm not sure what your code is trying to accomplish, but give this a whirl. It might be better than all that looping and cursors. I don't have any sample data/tables so I'm largely guessing here.
    update inv_dc_tmp i
    set    i.total_inv_qty =
              (select sum(t.inv_forecast_qty)
               from   inv_dc_tmp t
                     ,tr_periods p
               where  t.period_id = p.period_id
               and    p.status_flag = 1
               and    p.period_id >= 46
               and    t.period_id     = i.period_id - 1
               and    t.item_id       = i.item_id
               and    t.dc_id         = i.dc_id
    where exists
              (select 1
               from   tr_periods p
               where  p.period_id = i.period_id - 1
               and    p.status_flag = 1
               and    p.period_id >= 46
    ;Extremely UNtested.

  • ORA-01002 run-time error for help

    Hi, All:
    I modified little in Sample10.pc of PRO*C sample code to fit both NT and
    Linux using 8i version precompiler, with VC++ and GCC Compiler respectively.
    All process were fine when they connected to a DB Server(8i version), but
    when they connected to the other Server(8 version), the error : ORA-01002
    (Fetch out of sequence) was always issued at run-time. I checked the error
    message and found that the program was stuck on the "PREPARE" description. I
    have spent much more time debugging, but it still didn't work. Could you
    help me? I'm so preciated.
    Best regards,
    Yen-Gou Pan
    null

    Hello,
    This error comes when  there is an OpenSQL statement that tries to insert a record into a database table that is already existing.
    You need to implement  SAP Note 196113 and 1041894 along with technical consultant to help and overcome the issue.
    Br,
    Tushar

  • Encounter ORA-01002 when calling OCIStmtFetch2 to fetch blob data

    Oracle Version:Release 10.2.0.1.0
    Description:
    We use these two functions to fetch the content of blob field dynamically in batch mode:
    OCIDefineByPos(OCI_DYNAMIC_FETCH)
    OCIDefineDynamic(callbackfun->cbf_get_data)
    We allocate fixed memory to fetch data in order to using compact memory.
    If the size of blob to be fetched is larger than the allocated memory size, the fetch can not be done in one call, which need to be interrupted.
    Those records would remain in cache and can only be fetched until calling OCIStmtFetch2 next time.
    The callback function:cbf_get_data, achieves this by returning OCI_ROWCBK_DONE, which marks current fetch interrupted.
    It would not return OCI_CONTINUE, because OCI_CONTINUE can not interrupt current fetch procedure in time.
    We made a sample code test, and found this logic only works when fetching small rows (nearly 800 rows). Exceptions occurred when fetching more rows(>=1000 rows).
    For example, among these 2 cases,
    1.(OCIStmtFetch2(m_stmthp,m_errhp,(ub4)800,OCI_FETCH_NEXT,(sb4)OCI_FETCH_RELATIVE,OCI_DEFAULT)
    2.(OCIStmtFetch2(m_stmthp,m_errhp,(ub4)1000,OCI_FETCH_NEXT,(sb4)OCI_FETCH_RELATIVE,OCI_DEFAULT)
    only the 1st one work, but the 2nd.
    After function cbf_get_data returns OCI_ROWCBK_DONE, calling OCIStmtFetch2 did not enter into callback function cbf_get_data.
    And OCIErrorGet showed such error:
    ORA-01002: fetch out of sequence
    the total number of result set is about 100,000.
    We tried to set PREFETCH to a larger value in this way::
    OCIAttrSet(m_stmthp,OCI_HTYPE_STMT,(dvoid *)&rnum,0,OCI_ATTR_PREFETCH_ROWS,m_errhp);
    rtn=OCIAttrSet((dvoid *)m_stmthp, (ub4) OCI_HTYPE_STMT,(dvoid *)&preFetch, (ub4)sizeof(preFetch), OCI_ATTR_PREFETCH_MEMORY,m_errhp);
    but it did not help.
    Waiting for you guidance.
    Thanks in advance!
    -Andy
    Edited by: Andy Tong on 2010-10-22 上午12:29

    Here is our testing Code:
    #include "oci.h"
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #pragma comment(lib,"oci.lib")
    char buf1[5000];
    char buf2[5000];
    long datalen=5000;
    ub4 outpos=1;
    ub4 outpos2=2;
    int sum=0;
    int sum2=0;
    OCIError *m_errhp;
    OCIStmt *m_stmthp;
    char      LOBBuf[8006];
    long      LOBLen=8006;
    long     gindpp=0;
    ub2     grcpp=0;
    #define MAX_ROW_NUM 56338
    /* Fetch callback to specify buffers. */
    sb4 cbf_get_data(     dvoid*          ctxp,
                             OCIDefine*     dfnhp,
                             ub4               iter,
                             dvoid**          bufpp,
                             ub4**          alenpp,
                             ub1*          piecep,
                             dvoid**          indpp,
                             ub2**          rcpp)
         if(iter==0)
              sum=0;
         else if(iter>=858) //857 exception
              //LOBBuf,LOBLen
              //     sum+=LOBLen;
              //     if(sum>1057552-100*1024)
              sum=0;
              bufpp=(dvoid)0;
              alenpp=(ub4)0;
              *piecep = (ub1)OCI_ONE_PIECE;
              indpp = (dvoid ) 0;
              rcpp     = (ub2 ) 0;
              return(OCI_ROWCBK_DONE);     
         LOBLen=8006;
         bufpp=(dvoid)LOBBuf;
         alenpp=(ub4)&LOBLen;
         *piecep = (ub1)OCI_ONE_PIECE;
         indpp = (dvoid )&gindpp;
         rcpp     = (ub2 )&grcpp;
         return(OCI_CONTINUE);     
    BOOL CTest_ociApp::InitInstance()
         OCIEnv *          m_envhp;
         OCIServer *          m_srvhp;
         OCISvcCtx *          m_svchp;
         sword               rtn;
         char               sqlState[256];
         int               nativeErr;
         char               errTxt[256];
         unsigned long          bufLen=256;
         OCIDefine hDefine =  (OCIDefine ) 0;
         OCIDefine hDefine1 = (OCIDefine ) 0;
         OCIDefine hDefine2 = (OCIDefine ) 0;
         OCIDefine hDefine3 = (OCIDefine ) 0;
         OCIDefine hDefine4 = (OCIDefine ) 0;
         int i;
         OCILobLocator** lob_array;
         char username[255];
         char password[30];
         char dbname[30];
         char szSqlStr[255];
         ub4 preFetch= 10*1024*16;
         strcpy(username,"dlg25w");
         strcpy(password,"sa");
         strcpy(dbname,"WIN10G");
         OCIEnvCreate(&m_envhp, OCI_DEFAULT | OCI_OBJECT, 0, 0, 0, 0, 0, 0);
         OCIHandleAlloc( (dvoid *)m_envhp, (dvoid **)&m_errhp,OCI_HTYPE_ERROR,(size_t) 0, (dvoid **) 0);
         OCIHandleAlloc( (dvoid *)m_envhp, (dvoid **)&m_srvhp,OCI_HTYPE_SERVER,(size_t) 0, (dvoid **) 0);
         OCIHandleAlloc( (dvoid *)m_envhp, (dvoid **)&m_svchp,OCI_HTYPE_SVCCTX,(size_t) 0, (dvoid **) 0);
         OCIHandleAlloc( (dvoid *)m_envhp, (dvoid **)&m_stmthp,OCI_HTYPE_STMT,(size_t) 0, (dvoid **)0);
         OCIServerAttach(m_srvhp, m_errhp,(text *)dbname, strlen(dbname),(ub4) OCI_DEFAULT);
         OCILogon(m_envhp,m_errhp,&m_svchp,(text *)username,strlen(username),(text *)password,strlen(password),(text *)dbname,strlen(dbname));
         ub4     rnum=0;
         unsigned int len=0;
         //rtn=OCIAttrGet(m_envhp,OCI_HTYPE_ENV,(dvoid *)&rnum,&len,OCI_ATTR_CACHE_MAX_SIZE,m_errhp);
         OCIErrorGet((dvoid *) m_errhp,(ub4)1,(OraText *)sqlState,&nativeErr,(unsigned char*)errTxt,bufLen,(ub4) OCI_HTYPE_ERROR);
         len=4;
         rnum=83886080;
         rtn=OCIAttrSet(m_envhp,OCI_HTYPE_ENV,(dvoid *)&rnum,len,OCI_ATTR_CACHE_OPT_SIZE,m_errhp);
         rtn=OCIAttrGet(m_envhp,OCI_HTYPE_ENV,(dvoid *)&rnum,&len,OCI_ATTR_CACHE_OPT_SIZE,m_errhp);
         OCIErrorGet((dvoid *) m_errhp,(ub4)1,(OraText *)sqlState,&nativeErr,(unsigned char*)errTxt,bufLen,(ub4) OCI_HTYPE_ERROR);
         rnum=2000;
         sprintf( szSqlStr,"%s", "SELECT DATA FROM MF4");
         OCIStmtPrepare(m_stmthp, m_errhp, (text*)szSqlStr, (ub4)strlen(szSqlStr),(ub4) OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
    OCIAttrSet(m_stmthp,OCI_HTYPE_STMT,(dvoid *)&rnum,0,OCI_ATTR_PREFETCH_ROWS,m_errhp);
         /* initialize array of locators */
         OCIDefineByPos(m_stmthp, &hDefine2, m_errhp, (ub4)1,(dvoid *)0,(sb4)8006,SQLT_BIN,(dvoid *)0, (ub2 *)0, (ub2 *)0,(ub4) OCI_DYNAMIC_FETCH);//OCI_DYNAMIC_FETCH
         OCIDefineDynamic(hDefine2, m_errhp, (dvoid *)&outpos,(OCICallbackDefine)cbf_get_data);
         OCIStmtExecute(m_svchp, m_stmthp, m_errhp,(ub4)0, (ub4) 0,(const OCISnapshot*) 0,
              (OCISnapshot*)0,(ub4)OCI_DEFAULT);//OCI_STMT_SCROLLABLE_READONLY
         rtn=OCIAttrSet((dvoid *)m_stmthp, (ub4) OCI_HTYPE_STMT,(dvoid *)&preFetch, (ub4)sizeof(preFetch), OCI_ATTR_PREFETCH_MEMORY,m_errhp);
         while(1)
              rtn=OCIStmtFetch2(m_stmthp,m_errhp,(ub4)1000,OCI_FETCH_NEXT,(sb4)OCI_FETCH_RELATIVE,OCI_DEFAULT);
              OCIErrorGet((dvoid *) m_errhp,(ub4)1,(OraText *)sqlState,&nativeErr,(unsigned char*)errTxt,bufLen,(ub4) OCI_HTYPE_ERROR);
              if(rtn==OCI_NO_DATA)
                   break;
              else
         t0=GetTickCount()-t0;
         t0=0;
         OCIAttrGet((CONST void *)m_stmthp,OCI_HTYPE_STMT,(void *)&rows_fetched,(ub4 *)sizeof(rows_fetched),OCI_ATTR_ROW_COUNT ,m_errhp);
         printf("\n Total number of records:%d",rows_fetched);
         OCILogoff( m_svchp, m_errhp );
         OCIServerDetach( m_srvhp, m_errhp, OCI_DEFAULT );
         OCIHandleFree((dvoid *) m_stmthp, OCI_HTYPE_STMT);
         OCIHandleFree((dvoid *) m_svchp, OCI_HTYPE_SVCCTX);
         OCIHandleFree((dvoid *) m_srvhp, OCI_HTYPE_SERVER);
         OCIHandleFree((dvoid *) m_errhp, OCI_HTYPE_ERROR);
         getchar();
         return FALSE;
    }

  • HSODBC and ORA-01002

    Hi, guys!
    Why in this PL/SQL code "COMMIT;" comand causes an error ORA-01002 ?
    I use Microsift ODBC driver for Visual FoxPro.
    DECLARE
    TYPE EmpCurTyp IS REF CURSOR ;
    emp_cv EmpCurTyp;
    emp_new EmpCurTyp;
    tab_name VARCHAR2(30);
    D2 varchar(3);
    BEGIN
    OPEN emp_cv FOR 'select table_name T_N from [email protected]' ;
    LOOP
    FETCH emp_cv INTO tab_name;
    EXIT WHEN emp_cv%NOTFOUND;
    OPEN emp_new FOR 'select "ko" D2 from '&#0124; &#0124;tab_name&#0124; &#0124;'@ho.world ' ;
    LOOP
    FETCH emp_new INTO D2;
    commit; -- << causes an error ORA-01002 fetch out of sequence
    EXIT WHEN emp_new%NOTFOUND;
    END LOOP;
    ClOSE emp_new;
    END LOOP;
    CLOSE emp_cv;
    END;
    Thanks.
    null

    Thanks for the suggestion
    There are no "char(32767)"s in the package - altho there are "varchar2(32767)"s
    I have tried a variotion on the script, outputting the result to a new table instead of updating the enrolment - which ran fine so the error is in the update.
    I tried adding a step using the result in the temp table to update the enrolment table - and got my errors again. So there is something funny in my data. Nothing obvious shows.
    The full temp table contains 745292 records - when it failed 150 records had been written.
    I note that although I had expected only to find one record per enrolment, there are some where there are two (@#$%!! source system writing two "insert" audit records) - could my problem be that I am updating a record previously updated - where do I set the script to commit as it goes?
    Sandra

  • Bug and Fix: Report Template Preview displays ORA-01002

    Hi, omniscient All!
    Let me share some knowledge with you. There is an old APEX bug:
    BUG: preview report template errors with ORA-01002
    Report Template Preview/Copy Error
    Template Preview Error:
    You can definitely see it in 4.0, 4.1, 4.2, 4.2.1 versions: open any database application in AppBuilder, go to Shared Components→Templates, move cursor on Some Report Template row, click Preview Icon. Voilà:
    report error:
    ORA-01002: fetch out of sequenceI looked into Template Preview region's source and have found next WWV_RENDER_REPORT3.show call:
    wwv_render_report3.show(
        p_query => '
    select 1 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 2 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 3 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 4 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 5 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 6 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual
    order by 1',
        p_row_template_id => :f4000_p245_id,
        p_region_id => 88449328191587806
      );I have no wish to go deep into my further investigation, therefore I just call a cause: APEX Team, you forgot to set the value of P_PLUG_SOURCE_TYPE parameter.
    Workaround: While APEX Team will making a patch, those who can't wait it should fix it manually by executing next code:
    update &APEX_SCHEMA.wwv_flow_page_plugs
       set plug_source = q'{wwv_render_report3.show(
        p_query => '
    select 1 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 2 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 3 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 4 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 5 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual union
    select 6 COL1, ''[...]'' COL2, ''[...]'' COL3, sysdate COL4 from dual
    order by 1',
        p_row_template_id => :f4000_p245_id,
        p_region_id => 88449328191587806,
        p_plug_source_type => 'SQL_QUERY'
    where id = 14562627207747006
    /APEX_SCHEMA is schema where APEX was installed.
    Good luck,
    Alex
    Edited by: tiPPLer on 14.02.2013 17:14

    I wouldn't mind piggy-backing this to ask if the Report Template "shortcut" links at the top of the page can be updated to account for all sections that are now a part of the Report Template. "Before Each Row" and "After Each Row" sections are not listed in the shortcuts. There are also two shortcuts listed as "Before" and "After" which should probably be relabeled.
    Shane.

  • ORA-01002-Error in Select ... for update

    I would like to insert CLOB in a table (VP_EVENTS) with a primary key (eventid) with the following code:
    String content = "AAAAAAAAAAAAABBBBBBBBBBXXX";
    PreparedStatement cs = this.con.prepareStatement("INSERT INTO vp_events (eventid,term,participant)
    VALUES (?,?,empty_clob())");
    //Register IN-Parameter
    cs.setInt(1, 1);
    cs.setInt(2, 1);
    cs.setTimestamp(3, new java.sql.Timestamp( System.currentTimeMillis() ));
    //Execute statement
    cs.execute();
    cs.close();
    Statement stmt = con.createStatement();
    ResultSet clobLocatorSet = stmt.executeQuery( "SELECT PARTICIPANT FROM VP_EVENTS WHERE EVENTID=1 FOR UPDATE");
    // Get the CLOB-locator
    if (clobLocatorSet.next())
    oracle.sql.CLOB clob =
    ((oracle.jdbc.driver.OracleResultSet)
    clobLocatorSet).getCLOB(1);
    // Write CLOB-Data
    // The first parameter to plsql_write, is // the offset from which to start
    // writing, and the second parameter is the // data to be written.
    // plsql_length(), returns the length of // the data in the CLOB column
    countCLOB = clob.plsql_write(
    0,content.toCharArray());
    At the execution-point of the "Select for Update"-statement the oracle thin driver throws the Error "Fetch out of sequence ORA-01002".
    What's wrong?

    Connection conn = DriverManager.getConnection ("jdbc racle:thin:@myhost:1521:ORCL","scott", "tiger");
    conn.setAutoCommit(false);
    Statement stmt = conn.createStatement ();
    null

  • BUG: preview report template errors with ORA-01002

    I've checked on my local install and on apex.oracle.com. I go into the Templates of Shared Components and filter on the Report Templates. Although the preview icon is displayed to allow me to preview the template, I always receive "ORA-01002: fetch out of sequence" on an error page. The only types of Report Templates I have are of type "Generic Columns" so not sure if the problem exists with "Named Columns."
    Can anyone confirm this or correct me on this?
    Shane.

    I wouldn't mind piggy-backing this to ask if the Report Template "shortcut" links at the top of the page can be updated to account for all sections that are now a part of the Report Template. "Before Each Row" and "After Each Row" sections are not listed in the shortcuts. There are also two shortcuts listed as "Before" and "After" which should probably be relabeled.
    Shane.

  • ORA-01002: fetch out of sequence- error when accesing oracle sp from c#

    We have a stored procedure when we exceute it from Sql plus tool ot Toad works fine. But when we call it from C# .ne code gives us the following error.
    ORA-01002: fetch out of sequence ORA-02063: preceding line from SQA1
    Please help.

    with out these lines it works
    (fae_primary_agent_ind = 'X') or
    ((fae_primary_agent_ind is null) and (agn_agt_comp_st_cd = ‘65’)
    This is the stored proc. It works in oracle. It does not work only when we call it from C#.
    CREATE OR REPLACE
    PROCEDURE abc (
    p_report_date IN VARCHAR2,
    p_cur OUT Getadrdata.t_cursor,
    p_run_mode OUT NUMBER
    AS
    v_report_dt DATE;
    backed_out NUMBER := 0;
    previously_paid NUMBER := 0;
    BEGIN
    v_report_dt := TO_DATE (p_report_date, 'DDMMYYYY');
    SELECT COUNT (*)
    INTO backed_out
    FROM r2t_adr_payment a, DUAL
    WHERE a.fap_acctg_dt = v_report_dt
    AND a.fap_status_cd = 'B';
    IF backed_out = 0
    THEN
         SELECT COUNT (*)
    INTO previously_paid
    FROM r2t_adr_payment a, DUAL
    WHERE a.fap_acctg_dt = v_report_dt
    AND a.fap_status_cd = 'P';
    END IF;
    IF backed_out > 0 or previously_paid > 0
    THEN
    p_run_mode := 2;
    OPEN p_cur FOR
    SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
    fae_address_ln1 address_line1, fae_address_ln2 address_line2,
    fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
    fae_bus_phone business_phone, fae_supv_region_cd region,
    fae_territory_cd territory, fae_market_cd market,
    -- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
    agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
    fae_agent_type_cd status_cd, fae_first_nm first_name,
    fae_last_nm last_name,
    rpt_agent_bonus_class_id p_agent_bonus_class_id
    FROM r2t_adr_epc_agent_info LEFT OUTER JOIN rgt_points
    ON fae_agent_nbr = rpt_agent_nbr
    LEFT OUTER JOIN p1t_tot_agent ON fae_agent_nbr =
    agn_agent_nbr
    INNER JOIN r2t_adr_payment
    ON fae_agent_nbr = fap_primary_agent_nbr
    WHERE FAE_AGENT_TYPE_CD = '41'
    AND rpt_acctg_dt = v_report_dt
    AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt
    AND fap_acctg_dt = v_report_dt
    AND fap_status_cd = 'B'
    UNION ALL
    SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
    fae_address_ln1 address_line1, fae_address_ln2 address_line2,
    fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
    fae_bus_phone business_phone, fae_supv_region_cd region,
    fae_territory_cd territory, fae_market_cd market,
    -- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
    agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
    fae_agent_type_cd status_cd, fae_first_nm first_name,
    fae_last_nm last_name,
    0 p_agent_bonus_class_id
    FROM r2t_adr_epc_agent_info
    LEFT OUTER JOIN p1t_tot_agent ON fae_agent_nbr =
    agn_agent_nbr
    INNER JOIN r2t_adr_payment
    ON fae_agent_nbr = fap_primary_agent_nbr
    WHERE fae_agent_type_cd = '13'
    AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt
    AND fap_acctg_dt = v_report_dt
    AND fap_status_cd = 'B';
    ELSE
    p_run_mode := 1;
    OPEN p_cur FOR
    SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
    fae_address_ln1 address_line1, fae_address_ln2 address_line2,
    fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
    fae_bus_phone business_phone, fae_supv_region_cd region,
    fae_territory_cd territory, fae_market_cd market,
    -- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
    agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
    fae_agent_type_cd status_cd, fae_first_nm first_name,
    fae_last_nm last_name,
    rpt_agent_bonus_class_id p_agent_bonus_class_id
    FROM r2t_adr_epc_agent_info LEFT OUTER JOIN rgt_points
    ON fae_agent_nbr = rpt_agent_nbr
    LEFT OUTER JOIN p1t_tot_agent ON fae_agent_nbr =
    agn_agent_nbr
    WHERE rpt_acctg_dt = v_report_dt
    -- Next line for testing of a subset of data - testing purposes only
    -- AND FAE_SUPV_REGION_CD ='002'
    AND FAE_AGENT_TYPE_CD = '41'
    AND (
    (RPT_AGENT_BONUS_CLASS_ID = '3' AND SUBSTR(FAE_EMPLMT_DT,1,2) <> '01' AND ADD_MONTHS(FAE_EMPLMT_DT, 7 ) <= v_report_dt) OR
    (RPT_AGENT_BONUS_CLASS_ID = '3' AND SUBSTR(FAE_EMPLMT_DT,1,2) = '01' AND ADD_MONTHS(FAE_EMPLMT_DT, 6 ) <= v_report_dt) OR
    (RPT_AGENT_BONUS_CLASS_ID = '1')
    AND (
    (fae_primary_agent_ind = 'X') or
    ((fae_primary_agent_ind is null) and (agn_agt_comp_st_cd = ‘65’)
    AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt
    UNION ALL
    SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
    fae_address_ln1 address_line1, fae_address_ln2 address_line2,
    fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
    fae_bus_phone business_phone, fae_supv_region_cd region,
    fae_territory_cd territory, fae_market_cd market,
    -- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
    agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
    fae_agent_type_cd status_cd, fae_first_nm first_name,
    fae_last_nm last_name, 0 p_agent_bonus_class_id
    FROM r2t_adr_epc_agent_info LEFT OUTER JOIN p1t_tot_agent
    ON fae_agent_nbr = agn_agent_nbr
    WHERE fae_agent_type_cd = '13'
    -- Next line for testing of a subset of data - testing purposes only
    -- AND FAE_SUPV_REGION_CD ='002'
    AND fae_primary_agent_ind = 'X'
    AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    --DBMS_OUTPUT.PUT_LINE ('no data ' || SQLERRM);
    NULL;
    WHEN OTHERS
    THEN
    --DBMS_OUTPUT.PUT_LINE ('error ' || SQLERRM);
    --OPEN p_cur FOR
    -- SELECT NULL
    -- FROM DUAL;
              RAISE;
    END abc;

  • ORA-01002: fetch out of sequence error when using Oracle Thin Driver 9i with Weblogic 6.1

    The simple program below is a client that executes a SELECT query -
    there are 13 rows in the table, of which 10 are printed when I run the
    program, then after that the ORA-01002 error is reported. I am not
    doing anything with LOBs, or updates. I've tried putting
    con.setAutoCommit(false) as well, but that does not do anything.
    Why am I getting this error? Can anyone help.
    Thanks
    -H
    Context ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,
    "t3://127.0.0.1:7001");
    PreparedStatement stmt = null;
    ResultSet rs = null;
    UserTransaction ut = null;
    try {
    ctx = new InitialContext(ht);
    javax.sql.DataSource ds
    = (javax.sql.DataSource) ctx.lookup ("jtaXADS");
    java.sql.Connection conn = ds.getConnection();
    // You can now use the conn object to create
    // Statements and retrieve result sets:
    ut = (UserTransaction)
    ctx.lookup("javax.transaction.UserTransaction");
    ut.begin();
    stmt = conn.prepareStatement("select firstname,surname from
    EMPLOYEE ");
    stmt.executeQuery();
    rs = stmt.getResultSet();
    // Close the statement and connection objects when you are finished:
    while (rs.next())
    System.out.println("Result is " + rs.getString("firstname") + " " +
    rs.getString("surname"));
    ut.commit();
    stmt.close();
    conn.close();
    catch (Exception e) {
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();
    rs.close();}
    catch (Exception e) {
    // a failure occurred
    e.printStackTrace();

    Thanks everybody.
    I have tried this, calling ut.begin() first before getConnection,
    however no difference. However the problem goes away if I call
    stmt.setFetchSize(100);
    But I would prefer not to have to code this in every time!!!
    I see there is a setting within Weblogic Admin console to see the
    row-prefetch, but that is already set to 45 rows, so why do have to
    explicitly call stmt.setFetchSize(100)!!!
    Thanks
    -H
    "Carl Lawstuen" <[email protected]> wrote in message news:<[email protected]>...
    Agreed. The transaction must start before the connection. This is what
    is most likely causing the error.
    "Nils Winkler" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    one more thing: The UserTransaction has to be started before you obtain
    the connection, not after.
    Nils
    Humphrey wrote:
    The simple program below is a client that executes a SELECT query -
    there are 13 rows in the table, of which 10 are printed when I run the
    program, then after that the ORA-01002 error is reported. I am not
    doing anything with LOBs, or updates. I've tried putting
    con.setAutoCommit(false) as well, but that does not do anything.
    Why am I getting this error? Can anyone help.
    Thanks
    -H
    Context ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,
    "t3://127.0.0.1:7001");
    PreparedStatement stmt = null;
    ResultSet rs = null;
    UserTransaction ut = null;
    try {
    ctx = new InitialContext(ht);
    javax.sql.DataSource ds
    = (javax.sql.DataSource) ctx.lookup ("jtaXADS");
    java.sql.Connection conn = ds.getConnection();
    // You can now use the conn object to create
    // Statements and retrieve result sets:
    ut = (UserTransaction)
    ctx.lookup("javax.transaction.UserTransaction");
    ut.begin();
    stmt = conn.prepareStatement("select firstname,surname from
    EMPLOYEE ");
    stmt.executeQuery();
    rs = stmt.getResultSet();
    // Close the statement and connection objects when you are finished:
    while (rs.next())
    System.out.println("Result is " + rs.getString("firstname") + " " +
    rs.getString("surname"));
    ut.commit();
    stmt.close();
    conn.close();
    catch (Exception e) {
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();
    rs.close();}
    catch (Exception e) {
    // a failure occurred
    e.printStackTrace();
    ============================
    [email protected]

Maybe you are looking for

  • Proof of deliver past USPS 120 day available tracking information

    An issue on an ebay selling forum has come to my attention that I would like clarification on. Some ebay sellers have had buyers claim INR through PayPal after the 120 day cutoff of USPS online tracking availability. The seller purchases a shipping l

  • Photoshop CS6 erratic eyedropper cursor bug

    Late 2008 Unibody MacBook Pro, running OS X 10.7.4 Lion, and Photoshop CS6 13.0. In Photoshop CS6, I have noticed that when using my Wacom Bamboo Fun tablet, the eyedropper tool will very often (almost always) display erratic behaviour when using the

  • Fixing path command in terminal, fixing path command in terminal

    I have "mangled" by system path env variable.... Can overwrite with export, but would like to make the correction permanent... which file?

  • TIMESTAMPDIFF rounding to 2 decimal places instead of 0

    Hi, Requirement is to find difference between two timestamp column, as known one we cannot perform arithmetic operation in non number type in rpd. Hence tried using TIMESTAMPDIFF function as below, TimeStampDiff(SQL_TSI_MINUTE, MONITOR_TIMESTAMP, ATT

  • Crosstalk on BT Vision

    My parents have had BT vision for a while now (I don't live there still they are just not very 'techy'), they seem to be experiencing quite a lot of 'crosstalking' of channels. An example would be whilst we were watching Sky Sports last week you coul