x

Can we create our own exceptions in oracle?

I am having a pl/sql procedure. I am handling exceptions in exception block. There are couple of logical errors which may occur during the process.

So, whenver there is a situation occurs other than oracle exceptions, I want to handle it programatically, and want to pass a reasonable message.

So, I am thinking whether we can create our own exceptions or not?

Is there anyway we can do this?

more ▼

asked Dec 16 '09 at 05:22 PM in Default

OraLearner gravatar image

OraLearner
1.3k 69 85 88

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Error numbers in the range -20000..-20999 are reserved for the user-defined errors. You can easily raise your own error and catch it later as an exception:

--- This code will throw ORA-20010

raise_application_error(-20010, 'Operation failed');

more ▼

answered Dec 16 '09 at 05:36 PM

Tariq Rahiman gravatar image

Tariq Rahiman
665 2 2 4

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x375
x50

asked: Dec 16 '09 at 05:22 PM

Seen: 909 times

Last Updated: Dec 16 '09 at 05:22 PM