Return cursor from Oracle global temporary tables, error ORA-01410: invalid ROWID

I have a stored procedure which does the following things:

  • insert input records into a global temporary table
  • create a cursor that selects record from another table that inner joins the temporary table
  • return the cursor

e.g.
OPEN p_cursor FOR
SELECT *
FROM emp
INNER JOIN temp_table
ON temp_table.department = emp.department;

Then I tried to execute the stored procedure from java code and I get ORA-01410: invalid ROWID error. If you google it, you’ll see the following explanation.

Cause: A ROWID was entered incorrectly. ROWIDs must be entered as formatted hexadecimal strings using only numbers and the characters A through F. A typical ROWID format is ‘000001F8.0001.0006′.
Action: Check the format, then enter the ROWID using the correct format. ROWID format: block ID, row in block, file ID

This doesn’t help me to solve the problem, but I found a thread on Oracle forum that mentioned about preserve rows (Global Temporary tables for returning resultsets to ODP.NET client app), so in my case, this error occurs because when creating the temporary table, it is set to ON COMMIT DELETE ROWS. To fix this just change it to ON COMMIT PRESERVE ROWS, so your records will still exist while you trying to get the resultset. e.g:

CREATE GLOBAL TEMPORARY TABLE temp_table (
department     VARCHAR2(50))
ON COMMIT PRESERVE ROWS;

About these ads

One thought on “Return cursor from Oracle global temporary tables, error ORA-01410: invalid ROWID

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s