Mohamed Houri’s Oracle Notes

June 10, 2008

When Other Then Exception

Filed under: Oracle — hourim @ 10:47 am

I have just posted a comment on this thread about what Tom Kyte consider as 99.99999999% a bug. I was wondering if, the following plsql code which I very often use when loading data bases, represents also a bug. A typical example is when we want to “initial load” a huge amount of client information. The requirements are:

  • Do not stop the initial load in case of error occurring during the treatment of one record (client information)
  • Log each record as “Successful” or “Not Successful with its corresponding Error”
  • Make your process restartable
  • Do not commit across fetch in order to avoid ORA-01555 rollback segment snapshot too old error
  • In order to fulfil these requirements, I came always to such a kind of plsql code

FOR r_client in c_client LOOP
-- set a savepoint here
savepoint sps_a_savep;
-- Create/Update/Delete or Do here what ever your want in order requirements
-- to achieve you requirements
-- Update successfull record
SET treated_record ='Y';
WHERE client_record = r_client.client_id;

-- Here there is a when other exception which is not followed by a RAISE

ROLLBACKTO sps_a_savep;
-- Update Unsuccessfull record with its error
     UPDATE  client
     SET treated_record ='N';
      error_code        =SQLERRM
      WHERE client_record = r_client.client_id;
-- Treat next record
-- Commit outside the loop in order to avoid ORA-01555

 RAISE;   -- it is here were I want also to make a comment(see below)

Hopefully this case it one of 0.0000001 cases for which the WHEN OTHER EXCEPTION not followed by a RAISE is not a bug. But now I understand why Tom Kyte is always saying that it had better for the WHEN OTHER EXCEPTION that ORACLE has not created it. Because even if we use it and we use the RAISE command we will lose the exact plsql line number which really causes the exception to be raised.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at

Tony's Oracle Tips

Tony Hasler's light hearted approach to learning about Oracle

Richard Foote's Oracle Blog

Focusing Specifically On Oracle Indexes, Database Administration and Some Great Music

Hatem Mahmoud Oracle's blog

Just another Oracle blog : Database topics and techniques

Mohamed Houri’s Oracle Notes

Qui se conçoit bien s’énonce clairement

Oracle Diagnostician

Performance troubleshooting as exact science

Raheel's Blog

Things I have learnt as Oracle DBA

Coskan's Approach to Oracle

What I learned about Oracle

So Many Oracle Manuals, So Little Time

“Books to the ceiling, Books to the sky, My pile of books is a mile high. How I love them! How I need them! I'll have a long beard by the time I read them”—Lobel, Arnold. Whiskers and Rhymes. William Morrow & Co, 1988.

Carlos Sierra's Tools and Tips

Tools and Tips for Oracle Performance and SQL Tuning

Oracle Scratchpad

Just another Oracle weblog


Dominic Brooks on Oracle Performance, Tuning, Data Quality & Sensible Design ... (Now with added Sets Appeal)

%d bloggers like this: