"ORA-01002: fetch out of sequence"
usually means that a SQL fetch has been issued after a prior commit has
closed a server side cursor.
The current default behaviour of the
Oracle JDBC driver is to autocommit SQL Statements. So it is possible
that a commit has been issued which you did not expect. Eg if you are
performing update statements inside the fetch loop, it is possible that
an automatic commit has been issued after the update which has closed
the fetch loop's cursor.
To remedy this, Disable "Auto Commit" for the used connection before using the statement "select ... for update".
Add following line of code to your program:
... OracleDataSource ods = new OracleDataSource(); ... Connection conn = ods.getConnection(); conn.setAutoCommit(false); // Setting AutoCommit to OFF
Remark:
If you subsequently perform any updates to the rows returned by the result set, disable autocommit and do not perform any manual commits if you still have additional rows to fetch. Any commit performed while any 'for update' cursor is still open cause subsequent fetches to return the ORA-1002 error.
If you subsequently perform any updates to the rows returned by the result set, disable autocommit and do not perform any manual commits if you still have additional rows to fetch. Any commit performed while any 'for update' cursor is still open cause subsequent fetches to return the ORA-1002 error.
Ref: 1016747.102,1027196.1,257914.1,18593.1
No comments:
Post a Comment