By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,557 Members | 1,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,557 IT Pros & Developers. It's quick & easy.

Stored Procedure - Handling all error code with a single condition !!

P: n/a
vj

Please let me know how can i handle any kind of error conditions with a
single (condition and continue handler).

I need to catch any kind of exception thrown in the procedure with
a single
( declare condition and a declare continue handler)

Thanks in advance.

Vijay

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
vj wrote:
Please let me know how can i handle any kind of error conditions with a
single (condition and continue handler).

I need to catch any kind of exception thrown in the procedure with
a single
( declare condition and a declare continue handler)

Thanks in advance.

Vijay

That should do it:
DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION, NOT FOUND
....

Keep me on record for saying that this is a really bad idea.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

P: n/a
I have to agree with Serge here. For instance, if your procedure gets a
-1224 SQLCODE (no database agent -- typically meaning your connection
has been forced), coding up a continue handler, especially if you're
processing result data inside the procedure, can mean your procedure
will loop forever. The negative offshoot of that is that at best you'll
have an db2fmp process orphaned on your system (for any FENCED
procedure) or at worst the agent won't be able to be forced off as
control is inside the procedure (for any NOT FENCED LANGUAGE C
procedure, or SQL procedures created pre-V82 ie FP7).

Serge Rielau wrote:
vj wrote:
Please let me know how can i handle any kind of error conditions with a
single (condition and continue handler).

I need to catch any kind of exception thrown in the procedure with
a single
( declare condition and a declare continue handler)

Thanks in advance.

Vijay

That should do it:
DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION, NOT FOUND
...

Keep me on record for saying that this is a really bad idea.

Cheers
Serge

Nov 12 '05 #3

P: n/a
Serge Rielau wrote:
vj wrote:
Please let me know how can i handle any kind of error conditions with a
single (condition and continue handler).

I need to catch any kind of exception thrown in the procedure with
a single
( declare condition and a declare continue handler)

Thanks in advance.

Vijay

That should do it:
DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION, NOT FOUND
...

Keep me on record for saying that this is a really bad idea.

Cheers
Serge


Kind of makes me think of the lame ON ERROR RESUME statement in Visual
Basic. It's a really sloppy way of (not) handling exceptions.

So I agree with Serge here.

-R-
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.