Oracle and "Object no longer exists" exceptions (ora-08103)

It's been a while since my last post; I've spent that last few weeks buried in the middle of a large application that we're porting from SQL Server to Oracle (purely for the customer's needs, not due to any issue with SQL Server).

It's been hard work with a major amount of refactoring, but nothing particularly blog-worthy. Until today, that is :)

I've spent the last 4 hours chasing down a strange "Object no longer exists" exception which was getting thrown at various points when I tried to execute particular stored procs. The exception wasn't particularly helpful in diagnosing the issue, and since I'm a bit of an Oracle noob, it's taken me a while. However, I'm sure that there are other Oracle noobs out there, so hopefully this will help someone.

Doing googles on the error throws up a number of nasty things about corrupt pages, bug patches etc. I was pretty sure from the start that it was unlikely to be any of those. Since the debugger wasn't being particularly helpful, I resorted to the time-honoured technique of commenting out large swathes of code until things worked, and then gradually (in true geeky binary-chop fashion) re-introducing it.

This finally nailed it down to an "open c for select..." statement that was returning a cursor over a result set out to the caller. Nothing unusual there, most of my stored procs are doing similar things. However, this one included a join to a global temporary table. Remove the join, everything works. Re-introduce the join and the fireworks begin again.

That was it. Problem solved. In Oracle, you can create temporary tables with two options, "on commit delete rows" and "on commit preserve rows". The first of these effectively dumps the temp table as soon as a commit occurs, whereas the second holds on to the data until the session ends. My temporary tables were created with the first option, meaning that as soon as the transaction they were embedded in committed, they got dumped. My C# code then tried to read from the cursor that was over this dead table, and we get the lovely ora-08103 exception.

The fix? For me, nice and easy. Just change to the "on commit preserve rows" option. Job done, and I'm off to bed.

Comments

# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar Thanks for this priceless info, Steve! You made my day! I was struggling for the full day on the same issue, and this blog solved it in a minute!
Left by Ranganath P. Kashyap on 8/4/2009 3:08 PM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar Wow.. Thank you so very much... I tried hours trying to figure out the problem.. really Appreciate you for posting this.
Left by Jaya on 9/29/2009 11:11 PM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar Object no longer exists exceptions are really great and very useful. Thanks for sharing.
Left by designer sunglasses on 11/4/2009 2:34 AM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar You saved my day, Steve! I really appreciate it.
Left by canfield on 12/26/2009 7:17 AM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar thanks a lot, we have been trying for this two days
it works fine in oracle db but not in .net application
Left by sankee on 12/30/2009 1:54 PM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar Thanks a lot .... Solved our problem.....
Left by rocky on 1/19/2010 10:39 AM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar you can still have the 'on commit delete rows' option. What can be done is put a commit just before the code where the global temporary table is involved. you will not see the 08103 error.
Left by Vinod on 2/17/2010 10:44 PM
# re: Oracle and "Object no longer exists" exceptions (ora-08103)
Gravatar I was going mad with this issue for several hours until I read your answer.

Hat down for this :)
Left by Aleksandar on 7/2/2010 11:12 AM

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

Please add 7 and 8 and type the answer here:

Preview Your Comment.