ORA-1002 FETCH OUT OF SEQUENCE IN PRO*C
제품 : PRECOMPILERS
작성날짜 : 1996-07-19
#### ORA-1002 : FETCH OUT OF SEQUENCE ####
ORA-1002 error가 의미하는 것은 user가 더이상 유효하지 않은 cursor로부터
fetch를 하려고 하기 때문이다.
이러한 경우의 가장 흔한 경우를 다음 두가지로 설명하겠다.
1) ORA-1403 등과 같이 NO DATA FOUND를 return하는 fetch작업을 수행할 때
: 즉 fetch는 항상 현재의 row를 return하며, 마지막 row를 return한 후에 더
retrieve할 data가 있는지 check하기 위해 한번 더 fetch를 수행하는데 이
때 특정 exit구문으로 loop를 종료시키지 않으면 ORA-1002 error를 return
한다.
DECLARE
EMP_NAME EMP.ENAME%TYPE;
CURSOR C1 IS SELECT ENAME FROM EMP;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO EMP_NAME;
END LOOP;
CLOSE C1;
END;
2) SELECT FOR UPDATE를 가진 cursor 의 fetch 작업 내에 commit이 있는 경우.
DECLARE
EMP_NAME EMP.ENAME%TYPE;
CURSOR C1 IS SELECT ENAME FROM EMP
FOR UPDATE OF SAL;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO EMP_NAME;
UPDATE EMP SET SAL = 50;
-- cannot do this commit in version 6
COMMIT;
END LOOP;
CLOSE C1;
END;
Database consistency를 유지하기 위해 user는 자신이 update/delete할
row를 select 시점에서 lock을 걸어두는 경우가 있는데 commit이나
roollback을 만나기 이전까지는 lock이 걸려있다.
위 예에서 select for update 로 cursor가 open되는 시점에 lock을 걸어
놓지만 fetch를 수행 중 commit을 만나 lock이 release된다.
이 때 cursor는 더 이상 유효하지 않으며 fetch out of sequence를
return한다.
해결책은 commit을 fetch loop의 바깥 쪽으로 빼거나 select for update
문을 사용하지 않아야 한다.
Jonathan,
If the queries execute fine in sqlplus then the issue is not with HS or the database. It has to do with the 3rd party app.
Similar Messages
-
Update table with BC4J results in ORA-1002: fetch out of sequence
In our BC4J application, any table updates result in an ORA-1002: fetch out of sequence error message. The code looks something like this:
EmpViewImpl voEmp = getEmpView ();
voEmp.setWhereClause ("id = :0");
voEmp.setWhereClauseParam (0, iEmpId);
voEmp.executeQuery ();
if (voEmp.hasNext ()) {
EmpViewRowImpl rowEmp = (EmpViewRowImpl) voEmp.first ();
rowEmp.setFirstName ("Larry");
getTransaction ().postChanges ();
getTransaction ().commit ();
This has something to do with a bug (according to the Oracle JVM release notes). Still, this is fairly basic BC4J code, copied straight from the BC4J documentation. So why won't it work? Is there a workaround?
I'm currently replacing all this code with straightforward executeCommand ("update emp set firstname='.......") commands. This isn't problem-free either, because the remaining BC4J-code isn't always directly aware of any changes made in the database this way.
We use Oracle 8.1.6.1.0 on Linux RedHat 6.2, and JDeveloper 3.1 on Windows 2000. We've deployed the BC4J application modules as EJB's into the Oracle 8i JVM.
Any help is much appreciated!!!We've got the exact same problem!
Please help us.... -
ProC code- error ORA-1002 fetch out of sequence
Hi,
we have an application currntly running on an HP UX system that uses Oracle 9i database.
the pro*C codes work fine with Oracle 9i, on the older system. however now we are migrating it to LINUX system (ORACLE 10g). in the new system we are facing issues with fetch statement
here is how we have the code:
the cursor statement:
EXEC SQL DECLARE diff_cns_list CURSOR FOR
select PREV.CNS_CODE,
PREV.CNS_DESCRIPTION,
PREV.CGP_CODE,
CURR.CNS_DESCRIPTION,
CURR.CGP_CODE
from NCIP_CNS_LIST PREV, NCIP_CNS_LIST CURR
where CURR.SAMPLE_DATE =
to_date('01' || :currdate || ' 00:00','ddyymm hh24:mi')
and PREV.SAMPLE_DATE =
to_date('01' || :prevdate || ' 00:00','ddyymm hh24:mi')
and PREV.CNS_CODE = CURR.CNS_CODE
and (PREV.CGP_CODE != CURR.CGP_CODE or
PREV.CNS_DESCRIPTION != CURR.CNS_DESCRIPTION);
======================
currdate=1106 (i.e. june 2011)
prevdate=1105 (i.e. may 2011)
======================
cursor is opened and then following fetch statement is run:
while( 1 )
exec sql FETCH diff_cns_list INTO :prev_vcns,
:prev_vdesc,
:prev_vcgp,
:curr_vdesc,
:curr_vcgp;
/* If no data found then exit from loop */
if( sqlca.sqlcode == 1403 )
break;
else if( sqlca.sqlcode != 0 )
vLOG_Msg(LOG_MSG_ERROR,"fniCmpNcipCnsList",
"ORACLE error on fetching diff_cns_list %s", sqlca.sqlerrm.sqlerrmc);
return( ERROR );
oravarterm( prev_vcns );
oravarterm( prev_vdesc );
oravarterm( prev_vcgp );
oravarterm( curr_vdesc );
oravarterm( curr_vcgp );
fprintf( output_fp,"'%s','%s','%s','%s','%s'\r\n",prev_vcns.arr,
prev_vdesc.arr,
prev_vcgp.arr,
curr_vdesc.arr,
curr_vcgp.arr);
the code runs fine in the old operating system (HP UX) where oracle 9i was used.
but fails in Oracle 10g(OS-LINUX).
the probable reason that we found out is that:
the fetch statement returns zero rows, that is the reason why this error is being displayed.
but Oracle 9i seemed to work out well with this.
we tried reducing the cursor conditions, where it fetches 3 rows. this is when is the fetch statement works fine.
the functionality of the code is that it should work fine even with no rows selected. Is there a way we can modfy the code to work with zero rows as well.
the error we are getting is : ORA-01002: fetch out of sequence
==========================
as per what is given in Oracle sites:
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.
========================
we have checked:
1>this is not the case and ORA-1403 not returned
2>No update statements involved , there is a insert statement which inserts data in this table
3>i am not clear with this one.
Could anyone please guide us through this, please?Note the name of this forum is SQL Developer (Not for general SQL/PLSQL questions) - so for issues with the SQL Developer tool. Please post these questions under the dedicated OCCI forum (you've posted there before).
Regards,
K. -
ORA-01002: fetch out of sequence! HELP NEEDED!
Hi, can someone help us (me)!
Application: Sun-ConcordeXAL 2.6
Clients: Sun-Oracle-7.2.3
Database: Linux-Oracle-8.0.5.1
(PS! if clients software change to XAL 2.7 and Oracle 8.0.4
then we get same error)
Maybe database configuration or client oracle configuration
problem we dont'no ...
HELP US(Me)
Andri
nullAndri Karniol (guest) wrote:
: Hi, can someone help us (me)!
: Application: Sun-ConcordeXAL 2.6
: Clients: Sun-Oracle-7.2.3
: Database: Linux-Oracle-8.0.5.1
: (PS! if clients software change to XAL 2.7 and Oracle 8.0.4
: then we get same error)
: Maybe database configuration or client oracle configuration
: problem we dont'no ...
: HELP US(Me)
: Andri
I met the same error message when I upgrade the database from
SCO-7.2.2.4 to Sun-7.3.4. It seems some Pro*C program can not
work anymore. It give me ORA-01002: fetch out of sequence.
Any idea in this case?
Rgds Johnny
null -
Oracle Report raises ORA-01002 Fetch out of sequence
ORA-01002 Fetch out of sequence in runtime execution of
oracle report 3.0 and 2.5 in client/server environment.
The same sql query works in sqlplus without any problem.
If I change the criteria (where clause) the error sometime
disappear. I can't explain this weird behaviour.
Oracle server version is 7.1.5 on Digital VMS.
Any Help will be welcome.
nullORA-01002 Fetch out of sequence in runtime execution of
oracle report 3.0 and 2.5 in client/server environment.
The same sql query works in sqlplus without any problem.
If I change the criteria (where clause) the error sometime
disappear. I can't explain this weird behaviour.
Oracle server version is 7.1.5 on Digital VMS.
Any Help will be welcome.
null -
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 -
Java.sql.SQLException: ORA-01002: fetch out of sequence
We are getting 'Fetch out of sequence' error whrn we try to execute a 'for update' query.
We are first inserting values into the DLX_ASSET table and if there is image to be inserted the particualr row is fetched using the query. The insert query inserts values into the database.
'SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE'. While executing this query we are getting this exception. This is not happening when we are trying it from our local machine. But its happening everywhere else where its deployed.
We are using Websphere Application Server 6 and Oracle 9i. We have set autommit to false before the method is called and are commiting the transaction only after the whole set of queries are executed.
Please see below the code snippet,
/* UPDATE HIGH RESOLUTION IMAGE INTO DLX_ASSET TABLE */
logger.logInfo("inside IF condition ,,,,,,,,,,,"+assetId);
String query ="SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE ";
logger.logInfo("QUERY is...."+query);
logger.logInfo("Connection closed:"+ con.isClosed());
psHighResObj =(OraclePreparedStatement) con.prepareStatement(query);
logger.logInfo("inside updating high res AFTER prepare statement"+psHighResObj);
rsHighRes = (OracleResultSet) psHighResObj.executeQuery(); logger.logInfo("inside updating high res image 1");
while (rsHighRes.next()) {
logger.logInfo("inside while high res image 2");
highResImg =(OrdImage)rsHighRes.getCustomDatum(1,OrdImage.getFactory());
highResImg.loadDataFromInputStream(assetCustomTo.getHighResolutionImageIn());
assetCustomTo.getHighResolutionImageIn().close();
logger.logInfo("before update high res");
UPDATE_QRY = "UPDATE DLX_ASSET SET HIGH_RES_IMAGE = ? WHERE ASSET_ID=" + assetId;
stmt1 =(OraclePreparedStatement) con.prepareCall(UPDATE_QRY);
highResImg.setSource(assetCustomTo.getHighresFileType(),"",assetCustomTo.getSys_file_name1());
highResImg.setContentLength(Integer.parseInt(assetCustomTo.getHighresFileSize()));
highResImg.setProperties();
logger.logInfo(" after update query asset id: " + assetId);
logger.logInfo(" query high res:: " + UPDATE_QRY);
stmt1.setCustomDatum(1, highResImg);
stmt1.execute();
logger.logInfo("after update high res");
//checking if thumbnail is present: if bulk upload thumb nail won't be present
the exception is occuring in the line 'rsHighRes = (OracleResultSet) psHighResObj.executeQuery();'
This is exception trace
java.sql.SQLException: ORA-01002: fetch out of sequence
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java(Inlined Compiled Code))
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java(Compiled Code))
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java(Compiled Code))
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:1198)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2400)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at com.deluxe.imax.dataaccess.impl.extended.TelevisionAssetCustomDAOImpl.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.ejb.TelevisionFacadeJBean.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.handler.TelevisionHandler.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.action.WebNewAction.processExecute(Unknown Source)
at com.deluxe.imax.business.framework.BaseAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1284)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1241)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:136)
at com.deluxe.imax.business.framework.security.SecurityFilter.doFilter(Unknown Source)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:121)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:671)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.ja
Please share your feedback.
Thanks in advance!
Edited by: Sanu Sasidharan on May 11, 2011 4:26 AMHi Peter,
We tried pointing to the same database from local as well as QA. Works from local but not from QA.
assetId is the generated primary key in the same method.
Yes the exception is thrown from execute statement itself. the logger put just after the execute is not coming.
This is the method
public boolean createWebElectronicTrailersAsset(TelevisionResultDTO[] teleResultDTO, OracleConnection con) throws DAOException {
methodName ="createWebElectronicTrailersAsset(TelevisionResultDTO[] teleResultDTO,OracleConnection con) :: ";
//Value to be returned by method
boolean createInd = false;
OraclePreparedStatement psHighResObj = null;
OraclePreparedStatement psThumbnailObj = null;
OracleResultSet rsHighRes = null;
OracleResultSet rsThumbnail = null;
PreparedStatement psmt = null;
OraclePreparedStatement stmt1 = null;
OraclePreparedStatement stmt2 = null;
OrdImage highResImg = null;
OrdImage thumbnailImg = null;
ImaxGroupsTO groupsTO = null;
try {
long tvAssetId = 0;
long assetId = 0;
long cst_dwnld_asset_id = 0;
AssetCustomTO assetCustomTo = null;
AssetCustomDownloadTO assetCustDwnldTO = null;
CustomTVAssetTO tvAssetTo = null;
String DLX_ASSET_QRY = "";
String UPDATE_QRY = "";
String DLX_ASSET_TV_QRY = "";
String DLX_CUSTOM_DOWNLOAD_ASSET = "";
int k = 1;
for (int iCount = 0; iCount < teleResultDTO.length; iCount++) {
tvAssetId = (int) OraclePKGenerator.getInstance().getKey(InternalConstants.TV_ASSET_SEQUENCE);
assetId =(long) OraclePKGenerator.getInstance().getKey(InternalConstants.ASSET_SEQUENCE);
assetCustomTo = teleResultDTO[iCount].getAssetCustomTO();
tvAssetTo = teleResultDTO[iCount].getTv_Asset();
groupsTO= teleResultDTO[iCount].getGroupsTO();
if (assetCustomTo.getHighResolutionImageIn() != null) {
DLX_ASSET_QRY ="INSERT INTO DLX_ASSET("
+ "ASSET_ID,"
+ "CREATED_BY,"
+ "CREATED_DATE,"
+ "REVISED_BY,"
+ "REVISED_DATE,"
+ "FILE_NAME,"
+ "FILE_SIZE,"
+ "FILE_TYPE,"
+ "SYS_FILE_NAME,"
+ "HIGH_RES_IMAGE,"
+ "THUMBNAIL_IMAGE,"
+ "ASSET_STATUS_ID,"
+ "DMX_PART1_REF,"
+ "DMX_PRODUCT_ID_REF,"
+ "DMX_PRODUCT_DESC_REF,"
+ "ASSET_AVAIL_1_IND,"
+ "DMX_PART_2,"
+ "DMX_PRODUCT_2,"
+ "DMX_PRODUCT_DESC_2,"
+ "ASSET_AVAIL_2_IND,"
+ "EFFECTIVE_DATE,"
+ "EXPIRATION_DATE,"
+ "FILE_NAME1,"
+ "SYS_FILE_NAME1,"
+ "ASSET_TYPE_ID,"
+ "MATERIALS_CATEGORY,"
+ "PART_1_NOTES,"
+ "PART_2_NOTES,"
+ "PHY_ORDER_STATUS)"
+ "VALUES (?,?,SYSDATE,?,SYSDATE,?,?,?,?,ORDSYS.ORDImage.init(),"
+" ORDSYS.ORDImage.init(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
}else if(){
// condition if images are not uploaded
psmt = con.prepareStatement(DLX_ASSET_QRY);
k=1;
psmt.setLong(k++, assetId);
psmt.setString(k++, assetCustomTo.getCreated_by());
psmt.setString(k++, assetCustomTo.getRevised_by());
if(assetCustomTo.getAssetTextIn()!=null ){
psmt.setString(k++, assetCustomTo.getFile_name());
psmt.setString(k++, assetCustomTo.getFile_size());
psmt.setString(k++, assetCustomTo.getFile_type());
psmt.setString(k++, assetCustomTo.getSys_file_name());
/* UPLOAD PREVIEW VIDEO FILE INTO FILE SYSTEM .....*/
Util.upLoadFile(assetCustomTo.getAssetTextIn(),assetCustomTo.getSys_file_name());
}else if(assetCustomTo.getAssetTextIn()==null && assetCustomTo.getSys_file_name() != null
&& assetCustomTo.getSys_file_name().trim().length() != 0){
psmt.setString(k++, assetCustomTo.getFile_name());
psmt.setString(k++, assetCustomTo.getFile_size());
psmt.setString(k++, assetCustomTo.getFile_type());
psmt.setString(k++, assetCustomTo.getSys_file_name());
} else{
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setLong(k++, assetCustomTo.getAsset_status_id());
if(assetCustomTo.getDmx_product_desc_1()!=null && assetCustomTo.getDmx_product_desc_1().trim().length()!=0){
psmt.setLong(k++, assetCustomTo.getDmx_part_1());
psmt.setLong(k++, assetCustomTo.getDmx_productId_1());
psmt.setString(k++, assetCustomTo.getDmx_product_desc_1());
psmt.setString(k++, assetCustomTo.getAsset_order_status_1());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getDmx_product_desc_2()!=null && assetCustomTo.getDmx_product_desc_2().trim().length()!=0){
psmt.setLong(k++, assetCustomTo.getDmx_part_2());
psmt.setLong(k++, assetCustomTo.getDmx_productId_2());
psmt.setString(k++, assetCustomTo.getDmx_product_desc_2());
psmt.setString(k++, assetCustomTo.getAsset_order_status_2());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getEffectiveDate()!=null){
psmt.setTimestamp(k++, assetCustomTo.getEffectiveDate());
}else{
psmt.setNull(k++,Types.TIMESTAMP);
if(assetCustomTo.getExpirationDate()!=null){
psmt.setTimestamp(k++, assetCustomTo.getExpirationDate());
}else{
psmt.setNull(k++,Types.TIMESTAMP);
psmt.setString(k++, assetCustomTo.getHighresFileName());
if(assetCustomTo.getSys_file_name1()!=null && assetCustomTo.getSys_file_name1().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getSys_file_name1());
}else{
psmt.setNull(k++, Types.VARCHAR);
psmt.setLong(k++, assetCustomTo.getAsset_type_id());
psmt.setLong(k++, assetCustomTo.getMaterialCategory());
if(assetCustomTo.getPart_notes_1()!=null && assetCustomTo.getPart_notes_1().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getPart_notes_1());
}else{
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getPart_notes_2()!=null && assetCustomTo.getPart_notes_2().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getPart_notes_2());
}else{
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getDmx_product_desc_1()!=null){
psmt.setLong(k++,assetCustomTo.getPhy_asset_status());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.execute();
if (assetCustomTo.getHighResolutionImageIn() != null) {
/* UPDATE HIGH RESOLUTION IMAGE INTO DLX_ASSET TABLE */
logger.logInfo("inside IF condition ,,,,,,,,,,,"+assetId);
String query ="SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE ";
psHighResObj =(OraclePreparedStatement) con.prepareStatement(query);
logger.logInfo("inside updating high res AFTER prepare statement"+psHighResObj);
rsHighRes = (OracleResultSet) psHighResObj.executeQuery();
while (rsHighRes.next()) {
highResImg =(OrdImage)rsHighRes.getCustomDatum(1,OrdImage.getFactory());
highResImg.loadDataFromInputStream(assetCustomTo.getHighResolutionImageIn());
assetCustomTo.getHighResolutionImageIn().close();
UPDATE_QRY = "UPDATE DLX_ASSET SET HIGH_RES_IMAGE = ? WHERE ASSET_ID=" + assetId;
stmt1 =(OraclePreparedStatement) con.prepareCall(UPDATE_QRY);
highResImg.setSource(assetCustomTo.getHighresFileType(),"",assetCustomTo.getSys_file_name1());
highResImg.setContentLength(Integer.parseInt(assetCustomTo.getHighresFileSize()));
highResImg.setProperties();
stmt1.setCustomDatum(1, highResImg);
stmt1.execute();
The connection in the method is passed from the service layer.
Thanks
Edited by: Sanu Sasidharan on May 12, 2011 2:30 AM -
ORA-01002: fetch out of sequence using multiple XA datasources
Hi,
I have a problem accessing multiple XA datasources :
- launch an sql request on datasource 1
- rs.next() on the resultset
- use the data to launch another sql request on datasource 2
After 10 iterations, the next() method throws an SQLException (ORA-01002: fetch out of sequence).
After further investigation, I noticed that :
- the problem doesn't occur if the same datasource is used for the 2 requests
- if I set the fetch size to 15 for the first request, the exception is thrown after 15 iterations (but I can't use this as a workaround because the number is potentially above the million).
Anyone experiencing the same problem ?
Thanks in advance
Nicolas
Here's my configuration :
- Weblogic 8.1 SP4
- JDK sun 1.4.2_04 (we have the same problem with various JDKs including JRockit)
- Oracle 10g
- Oracle thin driver xa 10.1.0.2.0
A JSP I use to reproduce the problem :
<pre><%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.ArrayList,
java.sql.Connection,
java.sql.PreparedStatement,
java.sql.ResultSet,
java.sql.SQLException,
javax.naming.InitialContext,
javax.naming.NamingException,
javax.sql.DataSource,
javax.transaction.UserTransaction"%>
<%!
public void launchTest() throws Exception {
Connection cnx =null ;
try {
getUserTransaction().begin();
// SQL access #1
cnx = getConnection("jdbc/xaDatasource1");
PreparedStatement stmt = cnx.prepareStatement("SELECT test_col from test_table");
ResultSet rs = stmt.executeQuery();
// iterate on resulset from SQL 1
int i=1;
while (rs.next()){ // SQL exception after 10 iterations
System.out.println(i + "");
i++;
// SQL access #2
Connection cnx2 = getConnection("jdbc/xaDatasource2");
// problem occurs even if we don't request
cnx2.close();
// end SQL access #2
getUserTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
try {
getUserTransaction().rollback();
} catch (Exception e1) {
e1.printStackTrace();
throw e;
} finally {
try {
if (cnx != null && !cnx.isClosed())
cnx.close();
} catch (Exception e1) {
e1.printStackTrace();
private UserTransaction getUserTransaction() throws NamingException {
return (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
private Connection getConnection(String jndiName) throws NamingException, SQLException {
DataSource ds = (DataSource) new InitialContext().lookup(jndiName);
return ds.getConnection();
%>
<%
launchTest();
SQL CODE :
CREATE TABLE TEST_TABLE ( TEST_COL NUMBER(2));
insert into test_table values(1);
insert into test_table values(2);
insert into test_table values(3);
insert into test_table values(4);
insert into test_table values(5);
insert into test_table values(6);
insert into test_table values(7);
insert into test_table values(8);
insert into test_table values(9);
insert into test_table values(10);
insert into test_table values(11);
%>
</pre>Nicolas Mervaillie wrote:
Hi,
I have a problem accessing multiple XA datasources :
- launch an sql request on datasource 1
- rs.next() on the resultset
- use the data to launch another sql request on datasource 2
After 10 iterations, the next() method throws an SQLException (ORA-01002: fetch out of sequence).
After further investigation, I noticed that :
- the problem doesn't occur if the same datasource is used for the 2 requests
- if I set the fetch size to 15 for the first request, the exception is thrown after 15 iterations (but I can't use this as a workaround because the number is potentially above the million).
Anyone experiencing the same problem ?Hi. This is a known weakness of Oracle. If the XA transactional context of a connection
changes during a result set processing, even if it is switched back correctly, the result
set is aborted. If the oracle driver has fetched 10 rows, that's all you get. The next
call to next() that needs real DBMS communication will fail.
By spec, an XA connection should be able to be swapped out and enlisted in different
transactions at a per-call granularity, so our pools allow that by default. Try setting
the KeepXAConnTillTxCOmplete setting in your pool.
When a connection is put back in the pool, if it is an XA connection we will suspend
any user tx, and test it with our own test tx, then re-enlist and re-start the user
tx in flight. This may be the context switch that kills the oracle result set.
Joe
>
Thanks in advance
Nicolas
Here's my configuration :
- Weblogic 8.1 SP4
- JDK sun 1.4.2_04 (we have the same problem with various JDKs including JRockit)
- Oracle 10g
- Oracle thin driver xa 10.1.0.2.0
A JSP I use to reproduce the problem :
<pre><%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.ArrayList,
java.sql.Connection,
java.sql.PreparedStatement,
java.sql.ResultSet,
java.sql.SQLException,
javax.naming.InitialContext,
javax.naming.NamingException,
javax.sql.DataSource,
javax.transaction.UserTransaction"%>
<%!
public void launchTest() throws Exception {
Connection cnx =null ;
try {
getUserTransaction().begin();
// SQL access #1
cnx = getConnection("jdbc/xaDatasource1");
PreparedStatement stmt = cnx.prepareStatement("SELECT test_col from test_table");
ResultSet rs = stmt.executeQuery();
// iterate on resulset from SQL 1
int i=1;
while (rs.next()){ // SQL exception after 10 iterations
System.out.println(i + "");
i++;
// SQL access #2
Connection cnx2 = getConnection("jdbc/xaDatasource2");
// problem occurs even if we don't request
cnx2.close();
// end SQL access #2
getUserTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
try {
getUserTransaction().rollback();
} catch (Exception e1) {
e1.printStackTrace();
throw e;
} finally {
try {
if (cnx != null && !cnx.isClosed())
cnx.close();
} catch (Exception e1) {
e1.printStackTrace();
private UserTransaction getUserTransaction() throws NamingException {
return (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
private Connection getConnection(String jndiName) throws NamingException, SQLException {
DataSource ds = (DataSource) new InitialContext().lookup(jndiName);
return ds.getConnection();
%>
<%
launchTest();
SQL CODE :
CREATE TABLE TEST_TABLE ( TEST_COL NUMBER(2));
insert into test_table values(1);
insert into test_table values(2);
insert into test_table values(3);
insert into test_table values(4);
insert into test_table values(5);
insert into test_table values(6);
insert into test_table values(7);
insert into test_table values(8);
insert into test_table values(9);
insert into test_table values(10);
insert into test_table values(11);
%>
</pre> -
ORA-01002 fetch out of sequence after suspend/resume transaction
Environment
- WebLogic 10.0.2.0
- Oracle thin driver 10.2.0.2.0
I iterate throw elements of ResultSet. During that global transaction is suspended and resumed. Then invoking of next on ResultSet caused following exception “java.sql.SQLException: ORA-01002: fetch out of sequence”.
I found that similar problem was reported in older WLS version ORA-01002 fetch out of sequence
Do you have any idea how I can fix it?
Best regards,
AdamOK, to get to the complete explanation, I suggest you open
an official support case. And I'm not trying to avoid the issue,
but fetching millions of rows out of the database to process
them outside is the wrong way to go. I highly recommend
DBMS-side logic in stored procedures to do the raw data processing. -
ORA-01002/ Fetch out of sequence on lazy loading
Hello,
We are facing an oracle SQLException (ORA-01002: fetch out of sequence)
while we are trying to get a field (retrieved via lazy loading) from an
object that was retrieved using a kodoquery.
This error only occurs during performance testing under a heavy load.
(100 concurrent users). For each thread we get a new persistencemanager
from the factory. And we have put the multithreaded option to true.
Can anyone help us with this problem?
Thanks in advance,
Kind Regards,
Niels Soeffers
Caused by: java.sql.SQLException: ORA-01002: fetch out of sequence
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at
oracle.jdbc.driver.T4CPreparedStatement.fetch(T4CPreparedStatement.java:1027)
at
oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:291)
at
oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:213)
at
com.solarmetric.jdbc.DelegatingResultSet.next(DelegatingResultSet.java:97)
at kodo.jdbc.sql.ResultSetResult.nextInternal(ResultSetResult.java:151)
at kodo.jdbc.sql.AbstractResult.next(AbstractResult.java:123)
at kodo.jdbc.sql.Select$SelectResult.next(Select.java:2236)
at
kodo.jdbc.meta.AbstractCollectionFieldMapping.load(AbstractCollectionFieldMapping.java:592)
at kodo.jdbc.runtime.JDBCStoreManager.load(JDBCStoreManager.java:521)
at
kodo.runtime.DelegatingStoreManager.load(DelegatingStoreManager.java:133)
at kodo.runtime.ROPStoreManager.load(ROPStoreManager.java:79)
at kodo.runtime.StateManagerImpl.loadFields(StateManagerImpl.java:3166)
at kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.java:3265)
at kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java:1386)
at
com.ardatis.ventouris.domain.OntvangstReeks.jdoGetontvangstTransacties(OntvangstReeks.java)
at
com.ardatis.ventouris.domain.OntvangstReeks.getStatus(OntvangstReeks.java:72)
at
com.ardatis.ventouris.service.financien.transfer.FinancienTOAssembler.getOntvangstReeksBaseTO(FinancienTOAssembler.java:71)
at
com.ardatis.ventouris.service.financien.transfer.FinancienTOAssembler.getOntvangstReeksBaseTOs(FinancienTOAssembler.java:84)
at
com.ardatis.ventouris.service.financien.FinancienManagerImpl.getOntvangstReeksBaseTOs(FinancienManagerImpl.java:241)
at
com.ardatis.ventouris.service.financien.ejb.FinancienManagerBean.getOntvangstReeksBaseTOs(FinancienManagerBean.java:62)
at sun.reflect.GeneratedMethodAccessor181.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:950)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158)
at
com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:128)
at $Proxy31.getOntvangstReeksBaseTOs(Unknown Source)
at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:123)We are using Oracle 10g and have tried multiple dirvers. (classes12.jar,
ojdbc14.jar)
Our kodo.properties ( actually the ra.xml we supply with the kodo.rar )
<connector>
<display-name>KodoJDO</display-name>
<description>Resource Adapter for integration of the Kodo Java Data
Objects (JDO) implementation with J2EE 1.3 compliant managed
environments</description>
<vendor-name>Solarmetric, Inc.</vendor-name>
<spec-version>1.0</spec-version>
<eis-type>jdo</eis-type>
<version>1.0</version>
<license>
<description>
See http://www.solarmetric.com for terms and license conditions.
</description>
<license-required>true</license-required>
</license>
<resourceadapter>
<managedconnectionfactory-class>kodo.jdbc.ee.JDBCManagedConnectionFactory</managedconnectionfactory-class>
<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>kodo.jdbc.ee.JDBCConnectionFactory</connectionfactory-impl-class>
<connection-interface>javax.resource.cci.Connection</connection-interface>
<connection-impl-class>kodo.runtime.PersistenceManagerImpl</connection-impl-class>
<transaction-support>XATransaction</transaction-support>
<config-property>
<description>A comma-separated list of query aggregate listeners
to add to the default list of extensions. Each listener must implement
the kodo.jdbc.query.JDBCAggregateListener interface.</description>
<config-property-name>AggregateListeners</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The kodo.jdbc.meta.ClassIndicator to use by default
for new mappings. The class indicator is responsible for tracking the
concrete class or subclass implemented by the object stored in each row of
a table.</description>
<config-property-name>ClassIndicator</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>in-class-name</config-property-value>
</config-property>
<config-property>
<description>The kodo.util.ClassResolver implementation that
should be used for JDO class resolution. Defaults to a JDO spec-compliant
resolver.</description>
<config-property-name>ClassResolver</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>spec</config-property-value>
</config-property>
<config-property>
<description>Details about various compatibiity levels for the
current environment.</description>
<config-property-name>Compatibility</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>The class name of either the JDBC java.sql.Driver, or
an instance of a javax.sql.DataSource to use to connect to the non-XA data
source.</description>
<config-property-name>Connection2DriverName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The password for the user specified in
Connection2UserName</description>
<config-property-name>Connection2Password</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of properties to be passed to
the non-XA JDBC Driver when obtaining a Connection. Properties are of the
form "key=value". If the given JDBC Driver class is a DataSource, these
properties will be used to configure the bean properties of the
DataSource. </description>
<config-property-name>Connection2Properties</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The URL for the non-XA data source.</description>
<config-property-name>Connection2URL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The username for the connection listed in
Connection2URL.</description>
<config-property-name>Connection2UserName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of
com.solarmetric.jdbc.ConnectionDecorator implementations to install on all
connection pools.</description>
<config-property-name>ConnectionDecorators</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The class name of either the JDBC java.sql.Driver, or
an instance of a javax.sql.DataSource to use to connect to the data
source.</description>
<config-property-name>ConnectionDriverName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The JNDI name of the connection factory to use for
finding non-XA connections. If specified, this is the connection that
will be used for obtaining sequence numbers.</description>
<config-property-name>ConnectionFactory2Name</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>jdbc/VentourisNonXA</config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of properties used to
configure the javax.sql.DataSource used as the non-XA ConnectionFactory.
Each property should be of the form "key=value", where "key" is the name
of some bean-like property of the data source.</description>
<config-property-name>ConnectionFactory2Properties</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The JNDI name of the connection factory to use for
obtaining connections.</description>
<config-property-name>ConnectionFactoryName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>jdbc/Ventouris</config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of properties used to
configure the javax.sql.DataSource used as the ConnectionFactory. Each
property should be of the form "key=value", where "key" is the name of
some bean-like property of the data source.</description>
<config-property-name>ConnectionFactoryProperties</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The password for the user specified in
ConnectionUserName</description>
<config-property-name>ConnectionPassword</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of properties to be passed to
the JDBC Driver when obtaining a Connection. Properties are of the form
"key=value". If the given JDBC Driver class is a DataSource, these
properties will be used to configure the bean properties of the
DataSource. </description>
<config-property-name>ConnectionProperties</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>This property dictates when PersistenceManagers will
retain and release data store connections. Available options are
"on-demand" for retaining a connection only during pessimistic
transactions and data store operations, "transaction" for retaining a
connection for the life of each transaction, or "persistence-manager" to
indicate that a persistence manager should retain and reuse a single
connection for its entire lifespan.</description>
<config-property-name>ConnectionRetainMode</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>transaction</config-property-value>
</config-property>
<config-property>
<description>The URL for the data source.</description>
<config-property-name>ConnectionURL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The username for the connection listed in
ConnectionURL.</description>
<config-property-name>ConnectionUserName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>Set to true if you''d like Kodo to copy all object
ids before returning them to your code. If you do not plan on modifying
identity objects, you can set this property to false to avoid the copying
overhead.</description>
<config-property-name>CopyObjectIds</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>Plugin used to cache data loaded from the data store.
Must implement kodo.datacache.DataCache.</description>
<config-property-name>DataCache</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The number of milliseconds that data in the data
cache is valid for. A value of 0 or less means that by default, cached
data does not time out.</description>
<config-property-name>DataCacheTimeout</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>-1</config-property-value>
</config-property>
<config-property>
<description>The type of data source in use. Available options
are "local" for a standard data source under Kodo''s control, or
"enlisted" for a data source managed by an application server and
automatically enlisted in global transactions.</description>
<config-property-name>DataSourceMode</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>enlisted</config-property-value>
</config-property>
<config-property>
<description>The kodo.jdbc.sql.DBDictionary to use for database
interaction. This is auto-detected based on the setting of
javax.jdo.option.ConnectionURL, so you need only set this to override the
default with your own custom dictionary or if you are using an
unrecognized driver.</description>
<config-property-name>DBDictionary</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>Whether to dynamically create custom structs to hold
and transfer persistent state in the Kodo data cache and remote
persistence manager frameworks. Dynamic structs can reduce data cache
memory consumption, reduce the amount of data serialized back and forth
under remote persistence managers, and improve the overall performance of
these systems. However, they increase application warm-up time while the
custom classes are generated and loaded into the JVM. Set to true to
enable dynamic data structs.</description>
<config-property-name>DynamicDataStructs</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>Specifies the default eager fetch mode to use.
Either "none" to never eagerly-load relations, "join" for selecting 1-1
relations along with the target object using inner or outer joins, or
"parallel" for selecting 1-1 relations via joins, and collections
(including to-many relations) along with the target object using separate
select statements executed in parallel.</description>
<config-property-name>EagerFetchMode</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>parallel</config-property-value>
</config-property>
<config-property>
<description>The number of rows that will be pre-fetched when an
element in a Query result is accessed. Use -1 to pre-fetch all
results.</description>
<config-property-name>FetchBatchSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>-1</config-property-value>
</config-property>
<config-property>
<description>The name of the JDBC fetch direction to use.
Standard values are "forward", "reverse", and "unknown".</description>
<config-property-name>FetchDirection</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>forward</config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of fetch group names that
PersistenceManagers will load by default when loading data from the data
store.</description>
<config-property-name>FetchGroups</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of query filter listeners to
add to the default list of extensions. Each listener must implement the
kodo.jdbc.query.JDBCFilterListener interface.</description>
<config-property-name>FilterListeners</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>Whether or not Kodo should automatically flush
modifications to the data store before executing queries.</description>
<config-property-name>FlushBeforeQueries</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>with-connection</config-property-value>
</config-property>
<config-property>
<description>If true, Kodo will order all SQL inserts, updates,
and deletes to meet your schema''s foreign key constraints. Defaults to
false.</description>
<config-property-name>ForeignKeyConstraints</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>If false, then the JDO implementation must consider
modifications, deletions, and additions in the PersistenceManager
transaction cache when executing a query inside a transaction. Else, the
implementation is free to ignore the cache and execute the query directly
against the data store.</description>
<config-property-name>IgnoreCache</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>Plugin used to manage inverse relations during flush.
Set to true to use the default inverse manager. Custom inverse managers
must extend kodo.runtime.InverseManager.</description>
<config-property-name>InverseManager</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of
com.solarmetric.jdbc.JDBCListener implementations to install on all
connection pools.</description>
<config-property-name>JDBCListeners</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The license key provided to you by SolarMetric. Keys
are available at www.solarmetric.com</description>
<config-property-name>LicenseKey</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value><KEY-REMOVED></config-property-value>
</config-property>
<config-property>
<description>Plugin used to handle acquiring locks on persistent
instances. Must implement kodo.runtime.LockManager.</description>
<config-property-name>LockManager</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>pessimistic</config-property-value>
</config-property>
<config-property>
<description>The number of milliseconds to wait for an object lock
before throwing an exception, or -1 for no limit.</description>
<config-property-name>LockTimeout</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>-1</config-property-value>
</config-property>
<config-property>
<description>LogFactory and configuration for Kodo''s logging
needs.</description>
<config-property-name>Log</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>kodo(DefaultLevel=WARN, Tool=WARN,
Runtime=WARN, SQL=WARN)</config-property-value>
</config-property>
<config-property>
<description>The mode to use for calculating the size of large
result sets. Legal values are "unknown", "last", and "query".</description>
<config-property-name>LRSSize</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>query</config-property-value>
</config-property>
<config-property>
<description>Plugin used to integrate with an external transaction
manager. Must implement kodo.runtime.ManagedRuntime.</description>
<config-property-name>ManagedRuntime</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>auto</config-property-value>
</config-property>
<config-property>
<description>Plugin used to configure management and profiling
capabilities.</description>
<config-property-name>ManagementConfiguration</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>none</config-property-value>
</config-property>
<config-property>
<description>The kodo.jdbc.meta.MappingFactory that will provide
the object-relational mapping information needed to map each persistent
class to the database.</description>
<config-property-name>MappingFactory</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>file</config-property-value>
</config-property>
<config-property>
<description>Plugin used to create metadata about persistent
types. Must implement kodo.meta.MetaDataLoader</description>
<config-property-name>MetaDataLoader</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>jdo</config-property-value>
</config-property>
<config-property>
<description>If true, then the application plans to have multiple
threads simultaneously accessing a single PersistenceManager, so measures
must be taken to ensure that the implementation is thread-safe. Otherwise,
the implementation need not address thread safety.</description>
<config-property-name>Multithreaded</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>If true, then it is possible to read persistent data
outside the context of a transaction. Otherwise, a transaction must be in
progress in order read data.</description>
<config-property-name>NontransactionalRead</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>If true, then it is possible to write to fields of a
persistent-nontransactional object when a transaction is not in progress.
If false, such a write will result in a JDOUserException.</description>
<config-property-name>NontransactionalWrite</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>Determines the persistence manager's behavior in
calls to getObjectById with a validate parameter of false. Use "check" to
check that a database record exists for the object and load its fetch
group fields. Use "hollow" to return a hollow instance.</description>
<config-property-name>ObjectLookupMode</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>check</config-property-value>
</config-property>
<config-property>
<description>Selects between optimistic and pessimistic (data
store) transactional modes.</description>
<config-property-name>Optimistic</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>Action to take when Kodo discovers an orphaned key in
the database. May be a custom action implementing
kodo.event.OrphanedKeyAction.</description>
<config-property-name>OrphanedKeyAction</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>log</config-property-value>
</config-property>
<config-property>
<description>The name of the concrete implementation of
javax.jdo.PersistenceManagerFactory that
javax.jdo.JDOHelper.getPersistenceManagerFactory () should create. For
Kodo JDO, this should be kodo.jdbc.runtime.JDBCPersistenceManagerFactory
or a custom extension of this type.</description>
<config-property-name>PersistenceManagerFactoryClass</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>kodo.jdbc.runtime.JDBCPersistenceManagerFactory</config-property-value>
</config-property>
<config-property>
<description>Persistence manager plugin and properties. If you
use a custom class, it must extend
kodo.runtime.PersistenceManagerImpl.</description>
<config-property-name>PersistenceManagerImpl</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>default</config-property-value>
</config-property>
<config-property>
<description>Configure this persistence manager factory to service
remote persistence managers.</description>
<config-property-name>PersistenceManagerServer</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>A comma-separated list of the class names of all
persistent classes to register whenever a persistence manager is
obtained.</description>
<config-property-name>PersistentClasses</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>com.ardatis.ventouris.domain.KwartaalVerhoging,
com.ardatis.ventouris.domain.Land, com.ardatis.ventouris.domain.Gemeente,
com.ardatis.ventouris.domain.Adres,
com.ardatis.ventouris.domain.ContactGegeven,
com.ardatis.ventouris.domain.AdresContactGegeven,
com.ardatis.ventouris.common.type.AdresType,
com.ardatis.ventouris.domain.OntvangstTransactie,
com.ardatis.ventouris.domain.OntvangstReeks,
com.ardatis.ventouris.domain.Ontvangst,
com.ardatis.ventouris.domain.Inkomen,
com.ardatis.ventouris.domain.loopbaan.LoopbaanPeriode,
com.ardatis.ventouris.common.type.InkomenSoort,
com.ardatis.ventouris.common.type.INSZ,
com.ardatis.ventouris.domain.Aangeslotene,
com.ardatis.ventouris.domain.NatuurlijkePersoon,
com.ardatis.ventouris.domain.Persoon, com.ardatis.ventouris.domain.Rol,
com.ardatis.ventouris.domain.Dossier,
com.ardatis.ventouris.common.type.Geslacht,
com.ardatis.ventouris.common.type.Taal,
com.ardatis.ventouris.common.type.Nationaliteit,
com.ardatis.ventouris.common.type.KostType,
com.ardatis.ventouris.domain.Verhoging,
com.ardatis.ventouris.domain.Aanvraag,
com.ardatis.ventouris.domain.AanvraagAansluitingSS,
com.ardatis.ventouris.domain.AanvraagToestand,
com.ardatis.ventouris.common.type.AanvraagToestandType,
com.ardatis.ventouris.domain.Factuur,
com.ardatis.ventouris.domain.TaakType, com.ardatis.ventouris.domain.Taak,
com.ardatis.ventouris.domain.BijdrageBerekening,
com.ardatis.ventouris.domain.calculationparameters.HerwaarderingsIndex,
com.ardatis.ventouris.domain.integration.asis.TempInterneOntvangst,
com.ardatis.ventouris.domain.calculationparameters.InkomenGrens,
com.ardatis.ventouris.domain.calculationparameters.BijdrageCategorie,
com.ardatis.ventouris.domain.calculationparameters.BijdrageCategorieGroep,
com.ardatis.ventouris.domain.integration.asis.TempOntvangstKinderbijslag,
com.ardatis.ventouris.domain.calculationparameters.JaarVerhogingParameter,
com.ardatis.ventouris.domain.calculationparameters.KwartaalVerhogingParameter,
com.ardatis.ventouris.domain.UitgaveReeks,
com.ardatis.ventouris.domain.Uitgave,
com.ardatis.ventouris.domain.Terugbetaling,
com.ardatis.ventouris.domain.BedragTerugbetaald,
com.ardatis.ventouris.domain.BijdrageSS</config-property-value>
</config-property>
<config-property>
<description>Plugin used to proxy second class object fields of
managed instances. Must implement kodo.util.ProxyManager.</description>
<config-property-name>ProxyManager</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>default</config-property-value>
</config-property>
<config-property>
<description>Plugin used to cache query results loaded from the
data store. Must implement kodo.datacache.QueryCache.</description>
<config-property-name>QueryCache</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>Plugin used to cache query compilation data. Must
implement java.util.Map. Does not need to be thread-safe -- it will be
wrapped via the Collections.synchronizedMap() method if it does not extend
kodo.util.CacheMap.</description>
<config-property-name>QueryCompilationCache</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>The default lock level to use when loading objects
within non-optimistic transactions. Set to none, read, write, or the
numeric value of the desired lock level for your lock
manager.</description>
<config-property-name>ReadLockLevel</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>read</config-property-value>
</config-property>
<config-property>
<description>Plugin used to communicate commit information among
JVMs. Must implement kodo.event.RemoteCommitProvider.</description>
<config-property-name>RemoteCommitProvider</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>Whether or not RemoteCommitEvents will include the
object Ids of objects added during the transaction.</description>
<config-property-name>RemoteCommitTransmitAddObjectIds</config-property-na -
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 issue
Hi,
I am facing a weird ORA-01002 issue where I am passing the payload by opening a cursor to a separate package which has the merge statement. This fails with ORA-01002 error when there are multiple updates for a single record on target. I read through the Oracle documentation which states "MERGE is a deterministic statement. That is, you cannot update the same row of the target table multiple times in the same MERGE statement."
My use case is such that there can be multiple updates in a day for an account and I have to maintain history for this on the target and I have a merge to do this. I am implementing SCD using triggers. What do you guys suggest to implement this solution? I need to update the same target table record multiple times in the same MERGE statement.
Calling procedure:
declare
acct load_<package>.account_list;
begin
OPEN acct FOR
SELECT DISTINCT<cols>
FROM <table> where action_type='UPDATE' order by account_updatedate;
load_<package>.<proc>(acct);
CLOSE acct;
end;
Merge package/procedure:
PROCEDURE merge_<proc(acct IN account_list)
AS
BEGIN
MERGE INTO <target_table> d USING (
SELECT DISTINCT *
FROM TABLE(<pipelined_proc>(acct))
) s
ON (<condition>
WHEN NOT MATCHED THEN INSERT (
<cols>
) VALUES (
<cols> );
COMMIT;
END;
Thanks,
VikramThe thread title's ORA-01002: fetch out of sequence error is potentially from the merge statement restarting to get a consistent view of the data.
It looks like "acct" is a REF CURSOR. If the merge decides to restart, the cursor cannot be restarted, so you will get a ORA-01002: fetch out of sequence error. That's a problem with using a ref cursor inside a SQL statement that modifies data - the statement can restart.
E.g. see AskTom: Ask Tom &quot;BEFORE Triggers Fired Multiple Times &quot;
The current URL for the statement
If the triggering statement of a BEFORE statement trigger is an UPDATE or DELETE statement that conflicts with an UPDATE statement that is running, then the database does a transparent ROLLBACK to SAVEPOINT and restarts the triggering statement. The database can do this many times before the triggering statement completes successfully. Each time the database restarts the triggering statement, the trigger fires. The ROLLBACK to SAVEPOINTdoes not undo changes to package variables that the trigger references. To detect this situation, include a counter variable in the package.
is PL/SQL Triggers -
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. -
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] -
Procedure throwing ORA-01002: fetch out of sequence error
Hello ..
I am not using any commits inside cursors with for update statements. This was running for the last 48 hrs and suddenly started throwing errors. Can anyone help me why it has problems sporadically. Code is enclosed here.
Is Sys_refcursor a dynamic cursor?.. I have my transaction_cursor as a sys_refcursor? Is that the problem here. If so, Do I need to remove commit inside the opening and closing of this cursor. The commit is executed for every 10000 rows..
Thanks in Advance
Kris
PROCEDURE PROCESS_EXECUTOR AS
cursor jobs_cursor is
select job_id from (
SELECT DISTINCT
job_id
FROM table_x )
ORDER BY job_id ) where ROWNUM <= 10;
transaction_cursor SYS_REFCURSOR;
tran tran_type;
sql_code varchar2(1024);
err_msg varchar2(1024);
cmt_counter number := 0;
BEGIN -- Process_Executor Start
for r_csr in jobs_cursor loop
OPEN transaction_cursor FOR SELECT * FROM table_y a
WHERE a.job_id = r_csr.job_id
order by create_timestamp, task_id;
LOOP
FETCH transaction_cursor BULK COLLECT INTO tran LIMIT 10;
EXIT WHEN tran.COUNT = 0;
FOR i IN 1..tran.COUNT LOOP
begin
if cmt_counter = 0 then
savepoint last_transaction;
end if;
cmt_counter := cmt_counter + 1;
exec_process1(tran(i));
if (cmt_counter = 10000 ) then
commit;
cmt_counter := 0;
end if;
exception
when others then
rollback to last_transaction;
end;
END LOOP;
END LOOP;
CLOSE transaction_cursor;
end loop;
commit;
END PROCESS_EXECUTOR;I'm always trying to avoid loops at all cost.
Anyway your jobs_cursor contains one open* and two close brackets* (see added comments)
I don't have a database available but as usually order by is the last sql clause maybe close bracket 1 should be commented out
PROCEDURE PROCESS_EXECUTOR AS
cursor jobs_cursor is select job_id
from (SELECT DISTINCT job_id -- OPEN BRACKET 1
FROM table_x
) -- CLOSE BRACKET 1
ORDER BY job_id
) -- CLOSE BRACKET 2
where ROWNUM <= 10;
transaction_cursor SYS_REFCURSOR;
tran tran_type;
sql_code varchar2(1024);
err_msg varchar2(1024);
cmt_counter number := 0;
BEGIN -- Process_Executor Start
for r_csr in jobs_cursor loop
OPEN transaction_cursor FOR SELECT * FROM table_y a
WHERE a.job_id = r_csr.job_id
order by create_timestamp, task_id;
LOOP
FETCH transaction_cursor BULK COLLECT INTO tran LIMIT 10;
EXIT WHEN tran.COUNT = 0;
FOR i IN 1..tran.COUNT LOOP
begin
if cmt_counter = 0 then
savepoint last_transaction;
end if;
cmt_counter := cmt_counter + 1;
exec_process1(tran(i));
if (cmt_counter = 10000 ) then
commit;
cmt_counter := 0;
end if;
exception
when others then
rollback to last_transaction;
end;
END LOOP;
END LOOP;
CLOSE transaction_cursor;
end loop;
commit;
END PROCESS_EXECUTOR;Regards
Etbin
Maybe you are looking for
-
How to create a help file for a VI
I want to create a help file describing my VI. How do i do that by clicking a control. How do I store the help file.
-
No sound in one event in iMovie 11'
I have lots of movies from my Panasonic camcorder in iMovie 11'. All look and sound fine except in one event (with several movies in it) there is no sound. None of the other events have the no sound effect so I am leaning toward it being a setting. D
-
I have been unable to uninstall google notifier following their instructions for my MacBook Pro. Any ideas what else to do? There is no icon in applications. I have an icon in activity moniter but I cannot delete it.
-
C3-01 screen smooth scrolling?
any tips on how to get the screen to scroll smoothly? When I first got this I was told by several people it just takes time to get used to a touch screen & soon I would love it! Well had it a year now & I still cant get it to scroll smoothly especia
-
Hi all We have set Oracle 10g express edition for our development server; but it has reached the maximum allotted 370MB Space... even after deleting few of my records it is not able to gain any space.. any ideas to trace this out. Is there a way to f