Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

valid uses of 'when others'?

smonJul 5 2011 — edited Jul 6 2011
Just wondered if I could get some discussion going around using when others exception blocks, I know generally they're frowned/spat on, and in some cases posters who've offered it up in sample code have been told it's a 'bug' and should be instantly removed.

I avoid using it, but have recently in one case. I'd be interested to hear any constructive/informative opinions.

We had a package acting as an interface between the mid-tier and an external app, messages would come into the mid-tier from the outside world, it'd pass them to the package and the logic in there would determine which proc on the external app to pass the message to. The message frequency was high, say about 50-100,000 per hour, 24/7.

So, 99.99% of the messages would pass through ok, a handful per day would 'error', mainly due to dependencies in the data not being fulfilled (ie, the message could be out of sequence, as the previous message was stuck in the gprs network somewhere).

Rather than bounce the errors back to the caller (mid-tier), which wouldn't know what to do with them, I added a when others and logged them to a table. Then at various points through the day I could review the table, fix, and resubmit the message.

I didn't even Raise inside the block, as I didn't see the point of sending the error back to the mid-tier, where it would just be ignored.

Have I broken many rules here? Am I about to be torn a new one? :o)

Or is that use case considered 'okay'??

thanks for any input.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 3 2011
Added on Jul 5 2011
14 comments
802 views