473,378 Members | 1,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to get 'message text' portion of error from SP

Hello All,

I have a procedure that is getting -443 after upgrading to V9.5 FP1.
The procedure was written to output only the SQLCODE. Here is the
output that is returned:

Value of output parameters
--------------------------
Parameter Name : V_OUTPUT
Parameter Value : ERR:-443

Return Status = 0
Error description from doc:

SQL0443N Routine "<routine-name>" (specific name "<specific-name>")
has
returned an error SQLSTATE with diagnostic text "<text>".

Explanation:

An SQLSTATE was returned to DB2 by routine "<routine-name>" (specific
name "<specific-name>"), along with message text "<text>". The routine
could be a user-defined function or a user-defined method.
My question is how can I modify this procedure to get all of the error
'message text'?

This is probably a very simple question, but I am just totally inept
at writing SPs.

Thanks in advance.

Jun 27 '08 #1
4 7704
Ian
jdokos wrote:
Hello All,

I have a procedure that is getting -443 after upgrading to V9.5 FP1.
The procedure was written to output only the SQLCODE. Here is the
output that is returned:

Value of output parameters
--------------------------
Parameter Name : V_OUTPUT
Parameter Value : ERR:-443

Return Status = 0
Error description from doc:

SQL0443N Routine "<routine-name>" (specific name "<specific-name>")
has
returned an error SQLSTATE with diagnostic text "<text>".

Explanation:

An SQLSTATE was returned to DB2 by routine "<routine-name>" (specific
name "<specific-name>"), along with message text "<text>". The routine
could be a user-defined function or a user-defined method.
My question is how can I modify this procedure to get all of the error
'message text'?
It would probably be helpful if you posted your stored proc so we can
see how you're doing this.

My guess is that you've set up something like,

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
set V_OUTPUT = 'ERR:' || char(SQLCODE);
END;
Jun 27 '08 #2
On Jun 19, 9:19*pm, Ian <ianb...@mobileaudio.comwrote:
jdokos wrote:
Hello All,
I have a procedure that is getting -443 after upgrading to V9.5 FP1.
The procedure was written to output only the SQLCODE. *Here is the
output that is returned:
Value of output parameters
* --------------------------
* Parameter Name *: V_OUTPUT
* Parameter Value : ERR:-443
* Return Status = 0
Error description from doc:
SQL0443N *Routine "<routine-name>" (specific name "<specific-name>")
has
* * * returned an error SQLSTATE with diagnostic text "<text>".
Explanation:
An SQLSTATE was returned to DB2 by routine "<routine-name>" (specific
name "<specific-name>"), along with message text "<text>". The routine
could be a user-defined function or a user-defined method.
My question is how can I modify this procedure to get all of the error
'message text'?

It would probably be helpful if you posted your stored proc so we can
see how you're doing this.

My guess is that you've set up something like,

* * DECLARE EXIT HANDLER FOR SQLEXCEPTION
* * * *BEGIN
* * * * * set V_OUTPUT = 'ERR:' || char(SQLCODE);
* * * *END;- Hide quoted text -

- Show quoted text -
Here is the handler portion of the SP:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
SET v_output = CONCAT('ERR:', CHAR(SQLCODE));
DECLARE CONTINUE HANDLER FOR SQLWARNING
SET l_sqlcode = 0;

I am trying to find a way to help the application team rewrite this to
get the complete error text from the procedure.

Thanks,
Jun 27 '08 #3
Ian
jdokos wrote:
On Jun 19, 9:19 pm, Ian <ianb...@mobileaudio.comwrote:
>jdokos wrote:
>>Hello All,
I have a procedure that is getting -443 after upgrading to V9.5 FP1.
The procedure was written to output only the SQLCODE. Here is the
output that is returned:
Value of output parameters
--------------------------
Parameter Name : V_OUTPUT
Parameter Value : ERR:-443
Return Status = 0
Error description from doc:
SQL0443N Routine "<routine-name>" (specific name "<specific-name>")
has
returned an error SQLSTATE with diagnostic text "<text>".
Explanation:
An SQLSTATE was returned to DB2 by routine "<routine-name>" (specific
name "<specific-name>"), along with message text "<text>". The routine
could be a user-defined function or a user-defined method.
My question is how can I modify this procedure to get all of the error
'message text'?
It would probably be helpful if you posted your stored proc so we can
see how you're doing this.

My guess is that you've set up something like,

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
set V_OUTPUT = 'ERR:' || char(SQLCODE);
END;- Hide quoted text -

- Show quoted text -

Here is the handler portion of the SP:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
SET v_output = CONCAT('ERR:', CHAR(SQLCODE));
DECLARE CONTINUE HANDLER FOR SQLWARNING
SET l_sqlcode = 0;
As expected.
I am trying to find a way to help the application team rewrite this to
get the complete error text from the procedure.
The solution may be to not use the exit handler for any SQLEXCEPTION.
Currently, your stored procedure runs successfully (as far as DB2 and
the calling application are concerned). The application has to parse
the V_OUTPUT variable to determine if the procedure was actually
successful.

If you don't trap the SQLEXCEPTION, your procedure will fail "properly"
-- meaning the application will see that the "CALL YOUR_SP()" statement
failed. You'd need to change your code to handle this, but you would
get the actual SQLCODE and DB2 error message text.

Sometimes it's useful to trap specific errors, only so you can provide
more descriptive error codes/messages. For example, SQLSTATE '23505'
(primary key violation) isn't always very useful. So you could trap
it and raise a more descriptive error:

declare pk_violation condition for sqlstate '23505';
declare exit handler for pk_violation
signal sqlstate '75025'
set message_text = 'A user with this employee ID already exists.';

Jun 27 '08 #4
Jeff,

You can also have ur exit handler capture the message_text instead and
pass that out as an output parameter..

DECLARE EXIT HANDLER FOR SQLEXCEPTION
get diagnostics exception 1 V_OUTPUT = message_text;

-SA

On Jun 20, 5:14*pm, Ian <ianb...@mobileaudio.comwrote:
jdokos wrote:
On Jun 19, 9:19 pm, Ian <ianb...@mobileaudio.comwrote:
jdokos wrote:
Hello All,
I have a procedure that is getting -443 after upgrading to V9.5 FP1.
The procedure was written to output only the SQLCODE. *Here is the
output that is returned:
Value of output parameters
* --------------------------
* Parameter Name *: V_OUTPUT
* Parameter Value : ERR:-443
* Return Status = 0
Error description from doc:
SQL0443N *Routine "<routine-name>" (specific name "<specific-name>")
has
* * * returned an error SQLSTATE with diagnostic text "<text>".
Explanation:
An SQLSTATE was returned to DB2 by routine "<routine-name>" (specific
name "<specific-name>"), along with message text "<text>". The routine
could be a user-defined function or a user-defined method.
My question is how can I modify this procedure to get all of the error
'message text'?
It would probably be helpful if you posted your stored proc so we can
see how you're doing this.
My guess is that you've set up something like,
* * DECLARE EXIT HANDLER FOR SQLEXCEPTION
* * * *BEGIN
* * * * * set V_OUTPUT = 'ERR:' || char(SQLCODE);
* * * *END;- Hide quoted text -
- Show quoted text -
Here is the handler portion of the SP:
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SET v_output = CONCAT('ERR:', CHAR(SQLCODE));
DECLARE CONTINUE HANDLER FOR SQLWARNING
SET l_sqlcode = 0;

As expected.
I am trying to find a way to help the application team rewrite this to
get the complete error text from the procedure.

The solution may be to not use the exit handler for any SQLEXCEPTION.
Currently, your stored procedure runs successfully (as far as DB2 and
the calling application are concerned). *The application has to parse
the V_OUTPUT variable to determine if the procedure was actually
successful.

If you don't trap the SQLEXCEPTION, your procedure will fail "properly"
-- meaning the application will see that the "CALL YOUR_SP()" statement
failed. *You'd need to change your code to handle this, but you would
get the actual SQLCODE and DB2 error message text.

Sometimes it's useful to trap specific errors, only so you can provide
more descriptive error codes/messages. *For example, SQLSTATE '23505'
(primary key violation) isn't always very useful. *So you could trap
it and raise a more descriptive error:

* * declare pk_violation condition for sqlstate '23505';
* * declare exit handler for pk_violation
* * * *signal sqlstate '75025'
* * * *set message_text = 'A user with this employee ID alreadyexists.';
You can also have ur exit handler capture the message_text instead and
pass that out as an output parameter..

DECLARE EXIT HANDLER FOR SQLEXCEPTION
get diagnostics exception 1 l_message_text = message_text;
Jul 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gema Gema | last post by:
I have a large collection of directories full of various files and am looking to create custom text files for the contents of each directory. Here is the situation: The directories are named...
3
by: Pradip Sagdeo | last post by:
I need to replace a portion of a url in a column as a result of changing servers. Is there a SELECT/REPLACE/UPDATE combination query that can do this. The table has close to a thousand entries...
1
by: Michael | last post by:
I have an application that will export two files to fixed width text to combine as a single text file. The first export will be a query containing header information for the file, the second query...
2
by: JASON.BUCK | last post by:
Access 2000 I have a text field named RoadName that contains the total road name, for example, "Johnson Road". I have another text field named StreetName that I would like to just contain the...
2
by: Darin | last post by:
I have the following code that opens a comma-delimited text file: connS = "Provider=Microsoft.Jet.OLEDB.4.0;" connS &= "Data Source=\tmp;" connS &= "Extended...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
4
by: Vish | last post by:
Hi, I need to make the text on a combobox that is disabled to be drawn with a black color. I was not able to find any help on this online. The drawItem seems to apply only for the dropdpwn...
8
by: Warren Post | last post by:
At <http://snow.prohosting.com/srcopan/dry/test.es.html>, you will see that the background image runs down the left margin. The right hand side of it is faded, watermark style, but it is one single...
19
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.