473,671 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
3 6371
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4332
by: Jen S | last post by:
I feel like I'm missing something obvious here, but I'm stumped... I have a stored procedure with code that looks like: INSERT INTO MyTableA ( ...fields... ) VALUES (...values...) IF (@@ERROR <> 0) BEGIN ROLLBACK TRANSACTION; RAISERROR('An error occurred in the stored proc.', 16, 1);
2
5119
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data store. I've done a fair amount of research on concurrency handling in newsgroups and other resources. Below is what I've come up as a standard for handling concurrency thru stored procedures. I am sharing with everyone so I can get some comments...
9
10293
by: dtwilliams | last post by:
OK, i'm trying to do some error checking on stored procedures and am following the advise in Erland Sommarskog's 'Implementing Error Handling with Stored Procedures' document. Can anybody help with my stored procedures and why it keeps erroring at the '-- Create new Address Detail stage'? The errorCode value that is being return in my web app is 0, so i'm not even sure why it's even raising the error!! Rather than executing the INSERT...
0
4271
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the experts here agree with the following? Would they add any other points? 1. If the shop standard calls for logging of application errors, a stored procedure should log any error that it encounters immediately upon detecting it and then return to the...
5
5155
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value 'D11' to :workdept and I have checked in the table that 6 rows should have returned. Any ideas why no resultset is being returned. import java.sql.*; import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.io.*; // Input/Output classes
2
9225
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
4
1690
by: William F. Robertson, Jr. | last post by:
One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around it and look for the output parameter to have a value. I would have thought this should have been posted in the sql newgroups, but I know exactly what they would say, and they would be correct. But when using asp.net ado.net command object. I...
10
16446
by: PJackson | last post by:
Trying to declare a simple handler for SQLEXCEPTION. Simple stored proc (UDB 8.2) ---- CREATE PROCEDURE TFBUDB.SMACF_SM_DI (IN POL_NBR CHAR(10) , OUT ErrNo INTEGER , OUT ErrMsg CHAR(80) ) ------------------------------------------------------------------------ -- SQL Stored Procedure ------------------------------------------------------------------------ P1: BEGIN
5
1982
by: william.david.anderson | last post by:
Hi there, I have a newbie stored procedures performance question that I'm hoping someone can answer. It seems like one of the benefits of using SQL stored procedures is that they can reduce the network traffic between the client and server, resulting in a performance gain. I'm wondering, though, if there's a performance penalty because it could be harder to reuse prepared statements with them.
0
8930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.