473,387 Members | 1,534 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,387 software developers and data experts.

Raise signal with dynamic message_text

Environment is DB2/LINUX 9.5.0.

I wonder if it is possible to set the MESSAGE_TEXT dynamically when
using the SIGNAL statement. The objective is to return more specific
information to the calling user or application. E.g. I would rather
return "Unknown value 42" than just "Unknown value".

The documentation says:

http://publib.boulder.ibm.com/infoce...c/r0004232.htm

SET MESSAGE_TEXT =

diagnostic-string-expression

An expression of type CHAR or VARCHAR that returns a character
string of up to 70 bytes to describe the error condition. If the
string is longer than 70 bytes, it is truncated.

So i thought something like this should work, but it does not (for me,
at least):

CREATE PROCEDURE customerror ()
BEGIN
DECLARE v_value CHAR(5) DEFAULT 'wrong';
DECLARE c_unknown CONDITION FOR SQLSTATE '90001';
SIGNAL c_unknown SET MESSAGE_TEXT = ('Unknown value ' | v_value);
END
@

Is it possible to set the MESSAGE_TEXT dynamically?

Regards,
Serman D.
--
Jun 27 '08 #1
1 3753
Serman D. wrote:
Environment is DB2/LINUX 9.5.0.

I wonder if it is possible to set the MESSAGE_TEXT dynamically when
using the SIGNAL statement. The objective is to return more specific
information to the calling user or application. E.g. I would rather
return "Unknown value 42" than just "Unknown value".

The documentation says:

http://publib.boulder.ibm.com/infoce...c/r0004232.htm

SET MESSAGE_TEXT =

diagnostic-string-expression

An expression of type CHAR or VARCHAR that returns a character
string of up to 70 bytes to describe the error condition. If the
string is longer than 70 bytes, it is truncated.

So i thought something like this should work, but it does not (for me,
at least):

CREATE PROCEDURE customerror ()
BEGIN
DECLARE v_value CHAR(5) DEFAULT 'wrong';
DECLARE c_unknown CONDITION FOR SQLSTATE '90001';
SIGNAL c_unknown SET MESSAGE_TEXT = ('Unknown value ' | v_value);
END
@

Is it possible to set the MESSAGE_TEXT dynamically?
Of course. Simply compose the text in a local variable and then use that
variable in the SIGNAL.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #2

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

Similar topics

1
by: Dominic | last post by:
Just in case someone is interested. I came up with this solution since my previous posting. Maybe you've got some other ideas or critcism. I'll listen ;-) Ciao, Dominic P.S. Python is...
1
by: Michael Pronath | last post by:
Hi, can I make sure that Python uses only async-signal safe glibc functions in signal handlers? For example, you must not call malloc or free in signal handlers, see...
4
by: Ahmed Ossman | last post by:
hi, I want to save the return value from the signal() function, what is the type of the variable. i.e. I want to do the following: <variable type?> ret_sig = signal(......); I need it soo...
3
by: LeTubs | last post by:
Hi I'm not sure if this is correct ...place to post but here goes This is what i'm trying to do, I want to write a signal / alarm handler ( I don't know which hence the posting here, as once I...
7
by: Amit Sharma | last post by:
Hi, I want to write a program, where until we give the value of j as non zero, it should go on asking us values of i and j, displaying the message "Division by zero: Floating point exception" for...
2
by: None | last post by:
Hello, 1. The prototype of function signal in signal.h: void (*signal(int sig, void (*func)(int)))(int); is some complex to me. Would you please explain it to me in detail with the C...
4
by: Charles Law | last post by:
Suppose a worker thread needs to signal to the main thread that an event has occurred. Ordinarily, any event raised by the worker thread will be on its own thread. How can the worker thread...
5
by: Ed Jensen | last post by:
I'm really enjoying using the Python interactive interpreter to learn more about the language. It's fantastic you can get method help right in there as well. It saves a lot of time. With that...
14
by: Rafe | last post by:
Hi, I've encountered a problem which is making debugging less obvious than it should be. The @property decorator doesn't always raise exceptions. It seems like it is bound to the class but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.