Database Error Messages

Release
toggle
  • 23ai
  • 21c
  • 19c
Updated
Jun 24, 2024

ORA-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:

  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 rerunning the statement.
  4. 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

  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. Rerun the statement after rebinding, then attempt to fetch again.
  4. Close cursors at the end of a request. Do not fetch from cursors across requests without rerunning the statement.