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
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.
timTim,
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 -
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 !!!!!! -
ORA-00164: autonomous transaction disallowed within distributed transaction
I have been trying to solve this problem for weeks now, I have posted this question everywhere I can think of, but I havent really received and answer that has helped, so now I am going to post it here hoping for an answer.
We are running 9iAS on Solaris and when the following stuff is run we are getting ORA-00164 errors. If you refresh the page a bunch of time the problem goes away. But it comes back the next time you try to execute the procedure again. Here are the cases when the problem shows up.
Editing the style:
PROCEDURE : PORTAL30.wwpob_app_style.edit_style
Saving changes to the banner for a page
PROCEDURE : PORTAL30.wwptl_banner.savecustom
Logging out
PROCEDURE : PORTAL30.wwsec_app_priv.logout
After setting the default user group and applying the changes:
PROCEDURE : PORTAL30.wwsec_app_user_mgr.edit_user
Creating a new group:
PROCEDURE : PORTAL30.wwsec_app_group_mgr.create_group
Opening the add portlet screen:
PROCEDURE : PORTAL30.wwv_main.main
There are a few other places but I don't have them documented. In ALL cases the problem goes away once we start and stop the Apache using the following comands:
/app/oracle/n_portal/Apache/Apache/bin/apachectl stop
ps -ef | grep httpd | grep n_portal
/app/oracle/n_portal/Apache/Apache/bin/apachectl start
After starting and stopping Apache the problem is gone for a little while (20-30 mins) then it starts coming back slowly (sometimes the problem is there then it is not). Once the problem is back if you continually press refresh on the browser (5-10 times) the page might appear, if the page does not appear you will see the
ORA-00164: autonomous transaction disallowed within distributed transaction
The following error appears in apache log (50% of the time) when Autonomous Transaction error shows up on the screen:-
DSHttpSessionBindingListenerImpl.valueUnbound : closing DS session : DSSession id = 5225534324468880950975536484
215 PortalSession id = 521335001720MERAJ
DSHttpSessionBindingListenerImpl.valueUnbound : closing DS session : DSSession id = -638034231325135430097553725
8001 PortalSession id = 992335001711JDALGLIESH
These errors might be related to dynamic services but we were had the problem long before Dynamic services was installed.
We want to start pre-production user testing as we have just had 11 developers building portlets for the company, but we cant do much with this error popping up every time a user wants to test it. We have one of the Oracle consultants here and he has asked the oracle developer group what the problem could be, and they seem to think it might be related to our use of DB links however, we never get the problem when we try to run a portlet that uses a database link.
Please help.
Jeff Dalgliesh
nullJay,
My name is Craig McCauley. I'm an Oracle Technical Manager working onsite at Unocal Indonesia. I'm with the Portal group in ATS.
When I got here the first thing we did was bump up init.ora parameters and apache confif parameters as suggested by the iPlatform group. We have thes sessions parameter (in init.ora) bumped up from 100 to 700. I'm watching v$session and the get these AT messages with as few as 70 total db sessions. Any help your group can give will be greatly appreciated.
Unocal is planning on implementing Oracle Portal globally - as a common interface. They have similar installs in Thailand and Houston and thus far have not seen the AT messages (although there has not been much development going on at those sites).
Thanks,
Craig -
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,
VitorHi,
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
RSDI'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
nullHello,
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:29Here 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;
} -
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 '| |tab_name| |'@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.
nullThanks 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:14I 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-00164 Autonomous Transactions in Distributed Env
Hi,
We are on 8.1.7 on AIX. We get ORA-00164 when we attempt to call an Autonomous transaction procedure whilst the main transaction has read a remote table.
In 8.1.6.0.0 this used to check us out with Ora-600, In 8.1.7 it gives error 164. I have read some postings stating that this limitation is expected to be fixed in Oracle server 8.2 or Oracle 9i Release 2.
Can somebody confirm this,
BTW what would 9i Release 2 mean - 9.2 or 9.0.2 ?
Also, is 8.2 out?
nullIs this question specific to Oracle9iAS Portal?
-
Set up autonomous transaction with error
Hi, Guys:
I try to set up autonomous transaction as a process after button pressed, I have this error:
1 error has occurred•ORA-06550: line 4, column 8: PLS-00710: Pragma AUTONOMOUS_TRANSACTION cannot be specified here
Could anyone give me a hint?
declare
PRAGMA AUTONOMOUS_TRANSACTION;
begin
if :P2200_CURRENT_SETTING='Y' then
update SOR_APEX_CONFIG
set CURRENT_SETTING='N';
end if;
update SOR_APEX_CONFIG
set APEX_SERVER=:P2200_APEX_SERVER,
PORT=:P2200_PORT,
APEX_STRING=:P2200_APEX_STRING,
CURRENT_SETTING=:P2200_CURRENT_SETTING,
APP_ID=:P2200_APP_ID,
CONFIG_DATE=sysdate
where ROWID=:P2200_ROWID;
commit;
end;I am using Oracle 11g, APEX 4.1
Edited by: lxiscas on Aug 23, 2012 1:56 PMHi Ixiscas,
I am able to reproduce this issue on my APEX Installation (4.1, 11g).
The reason maybe that the code is not executed directly but via dbms_sys_sq.parse_as_user().
My suggestion would be to move the functionality to a pl/sql procedure in the parsing schema and call this procedure in the page process.
Regards
Marc
Edited by: telemat on Aug 23, 2012 11:46 PM -
Pipeline function raised ORA-06519: active autonomous transaction detected
Hi All,
My name is John and I've got a problem which I need to share with all of you guru and experts. I've created the following pipeline function under the Oracle user ABC:
CREATE OR replace FUNCTION SomeFunction(p_from_date DATE, p_to_date DATE) RETURN T_TAB_A pipelined
IS
PRAGMA autonomous_transaction;
BEGIN
DELETE FROM temp_rcm;
INSERT INTO temp_rcm
SELECT * FROM int.facility fd,
int.capacity co
WHERE co.resource_name = fd.resource_name
AND co.trade_date = fd.trade_date
AND co.trade_date BETWEEN p_from_date AND p_to_date;
COMMIT;
FOR rec IN (SELECT co.*
FROM temp_rcm co
left join int.outage o
ON ( o.flag = 'Y'
AND o.reason_flag = 'F'
AND o.INTERVAL = co.INTERVAL
AND co.resource_name = o.resource_name )
ORDER BY co.INTERVAL,
co.name) LOOP
pipe ROW (T_A( rec.INTERVAL, rec.trade_date,
rec.resource_name,rec.day_of_week_long, rec.working_day, rec.peak));
END LOOP;
RETURN;
END SomeFunction;
I was able to compile and create the SomeFunction function successfully but when I executed it using the following command:
select * from table(SomeFunction(to_date('01/01/2010',to_date('01/01/2010')));
I was returned with the Oracle error - ORA-06519: active autonomous transaction detected and rolled back
I have searched through the web, such Oracle error occurs whenever the function has a missing 'COMMIT' or 'ROLLBACK' command inside an autonomous_transaction. But the fact is I have already included the 'COMMIT;' in the function. I suspected that the error was caused by the tables which I queried against (like int.facility and int.capacity) were all views that belonged to another schema called int. Or is that something that I miss in the function? Thank you for your time and assistance.
Regards,
Johnjohnwanng wrote:
Hi Guys,
Thank you for all your feedback. In addition to your reply, Bill, can you spare some time and provide us a simple example of the steps involved to implement the 'correct' implementation based on the queries that I've used. As I do not understand your vanilla approach. Much appreciated and thank you for the time again.
Regards,
JohnIf I had to guess, Billy may have meant something like this (untested):
CREATE OR REPLACE FUNCTION SomeFunction
( p_from_date IN int.facility.trade_date%TYPE
, p_to_date IN int.facility.trade_date%TYPE
RETURN SYS_REFCURSOR
AS
rcur SYS_REFCURSOR;
BEGIN
OPEN rcur FOR
SELECT co.interval
, co.trade_date
, co.resource_name
, co.day_of_week_long
, co.working_day
, co.peak
FROM int.capacity co
JOIN int.facility fd ON fd.resource_name = co.resource_name
AND fd.trade_date = co.trade_date
LEFT OUTER JOIN int.outage o ON o.interval = co.interval
AND o.resource_name = co.resource_name
WHERE co.trade_date BETWEEN p_from_date AND p_to_date
AND o.reason_flag = 'F'
AND o.flag = 'Y'
ORDER BY co.interval
, co.name
RETURN rcur;
END;
/I made the following modifications:
1. I set the input parameter data types to match that of the table column you are checking against. A good practice to get into.
2. Removed the autonomous transaction and inserting into a temp table. In Oracle it's a good practice to perform everything in a single SQL statement if possible.
3. Changed the return data type to a SYS_REFCURSOR
Hope this helps and provides a good example.
Maybe you are looking for
-
How can I play my iTunes rental purchase on Apple TV from my Mac? Please?
Can anyone PLEASE tell me how to play a movie I have hired on iTunes on Apple TV? What button on the TV do I press? I can play the video on the computer but it won't work on the Apple TV. Please?
-
Select options validation in selection screen
Hi all, I have select options for plant in selection screen..I want to validate the Plants. and display the invalid plants in the selection screen itself....Since my report is for online purpose i am in need of this requirement...i dont want to print
-
FireContentsChanged doesbot work in 1.4.
I have a MyComboBoxModel which extends DefaultListModel and implements ComboBoxModel. I implemented the method as public void setSelectedItem(Object item) selectedItem = item; fireContentsChanged(this, -1, -1); I want to fire the fireConten
-
Hi i am preparing notes for a presentation and was wondering was software would be best for doing it. You may have seen the picture of steve jobs notes from the iphone keynote, http://www.spymac.com/upload/2007/01/11/LJRzUHAdOF.jpg What software woul
-
I have a USB external HDD in a Nextar3I enclosure.(1.5 TB seagate (I don't recall the exact ref)). I was on the original firmware of the router and the disk was recognixed perfectly. I did get some issues with the router locking up at time, so I upgr