473,406 Members | 2,208 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,406 software developers and data experts.

How can I output my own messages? Can anybody describe the Errorhandling please?

If I start an INSERT ... the Result is an "x Row(s) affected" on the
console.

Is it possible to print out my own messages (e.g. to output the value
of a variable)?

How can I do my own Errorhandling?
If I check, that a Parameter form my Procedure is wrong I want to stop
the Procedure with an Error (for example).

Markus

Nov 12 '05 #1
6 1567
If you are talking about stored procedure language, you can generate
your own error messages using SIGNAL (check in DB2 information center).

However DB2 SQL is a language just to talk to database, not to output
messages to file or screen. So you must program it in your client
application.

You can also write you own UDF to write messages to file, and you can
the UDF in SQL (at DeveloperWorkd you can find sample implementations).

-- Artur Wronski

Nov 12 '05 #2
Markus wrote:
If I start an INSERT ... the Result is an "x Row(s) affected" on the
console.

Is it possible to print out my own messages (e.g. to output the value
of a variable)?

How can I do my own Errorhandling?
If I check, that a Parameter form my Procedure is wrong I want to stop
the Procedure with an Error (for example).

Markus

Take a look at the SIGNAL statement.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
>Is it possible to print out my own messages (e.g. to output
the value of a variable)?
Yes, there are two ways.

1) In the CREATE PROCEDURE statement, add an OUT Text VARCHAR(100) or
the like. When CALLing the PROCEDURE, pass a "?" (without the quotes)
for that parameter. When the CLP finishes the CALL, it will display the
contents of all OUT parameters.

2) In the PROCEDURE itself after the variable is set, add a block with
a CURSOR:
BEGIN
DECLARE x CURSOR WITH RETURN TO CLIENT FOR VALUES Text;
OPEN x;
END.

After the PROCEDURE finsihes, the CLP will ouput the data the CURSOR
has access to.
How can I do my own Errorhandling?


This is explained in the "Application Development Guide: Programming
Server Applications" in "Chapter 3. SQL-Bodied Routines" section
"Condition Handlers in SQL Procedures".

B.

Nov 12 '05 #4
Both of your questions will help me a little bit.
But I have some problems with the out-parameter.
This is my procedure:
CREATE PROCEDURE test_output2(OUT txt VARCHAR(100))
LANGUAGE SQL
BEGIN
SET txt = 'Hello World';
END

This is my call:
CALL test_output2(?)

And this is the Errormessage:
DB2 SQL error: SQLCODE: -313, SQLSTATE: 07004, SQLERRMC: null

What I'm doing wrong?

Markus

Nov 12 '05 #5
Markus wrote:
Both of your questions will help me a little bit.
But I have some problems with the out-parameter.
This is my procedure:
CREATE PROCEDURE test_output2(OUT txt VARCHAR(100))
LANGUAGE SQL
BEGIN
SET txt = 'Hello World';
END

This is my call:
CALL test_output2(?)

And this is the Errormessage:
DB2 SQL error: SQLCODE: -313, SQLSTATE: 07004, SQLERRMC: null

What I'm doing wrong?


I don't know. The above steps work quite fine on my system. (DB2 V8.2.3 on
Linux)

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #6
Your example worked here (too) on Solaris.

I would check if the ? needs to be escaped.

B.

Nov 12 '05 #7

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

Similar topics

16
by: Chuck Amadi | last post by:
Sorry to bovver you again (again) here's script. I still can't see why the get_payload() doesn't produce the plain text message body of an emails in the testwwws users mailbox. As you can see I...
2
by: Lance Wynn | last post by:
Hello All, In case the subject wasn't completely clear, I just upgraded to Windows XP Pro from Windows 2000 Pro. All my ASP stuff seems to work, except that when an ASP page generates an error,...
1
by: Bari Allen | last post by:
I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First varchar(80) OUTPUT ,...
0
by: jean-gert nesselbosch | last post by:
hello everybody, does anybody know of standardization efforts concerning the output of w3cSchema/relaxNG-validating parsers ? I use libxml2 for validation-purposes (w3c-Schema and relaxNG) and...
2
by: jb | last post by:
Using ADO.NET from ASP.NET. Have a SqlConnection executing stuff (stored procedures) I would like to be able to retrieve informational messages from the SQL sps, which comment on what they are...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
1
by: Mike P | last post by:
I am trying to return an output parameter to my code on executing a stored procedure. In Query Analyzer, it works with no problem, but when I run my ASP code below, the output parameter never...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
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,...
0
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...

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.