OCI-01002
fetch out of sequence
Cause
A fetch was attempted from a cursor that is no longer valid. A PL/SQL cursor loop implicitly does fetches, and thus may also cause this error. Possible causes for this error include the following:
- Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned.
- If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error.
- Rebinding any placeholders in the SQL statement, then issuing a fetch before rerunning the statement.
- The database server will close cursors at a request boundary when RESET_STATE is active. An attempt to use the cursor after the request has ended can raise this error.
Action
- Do not issue a fetch statement after the last row has been retrieved - there are no more rows to fetch.
- Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE.
- Rerun the statement after rebinding, then attempt to fetch again.
- Close cursors at the end of a request. Do not fetch from cursors across requests without rerunning the statement.