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

Getting SQLERRMC into DB2 for LUW Stored Procedure

I'm trying to get the SQLERRMC info from the SQLCA into my SP so that I
can use the information it provides. I'm successfully getting the
SQLCODE and SQLSTATE and so added the SQLERRMC to the code which
obtains these. It doesn't seem to work however -

create procedure dbair001.sp001testerr
(
,OUT p_sqlstate CHAR(5)
,OUT p_sqlcode INTEGER
,OUT p_sqlerrmc VARCHAR(70)
)
specific dbair001.sp001testerr
begin
--
-- Declare return codes
--
DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE SQLERRMC VARCHAR(70);
--
-- Define working storage
--
declare v_dynstmt VARCHAR(100);
--
-- Define error handlers
--
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SELECT
SQLSTATE,
SQLCODE,
SQLERRMC
INTO
p_sqlstate,
p_sqlcode,
p_sqlerrmc
FROM
sysibm.sysdummy1;
--
-- Start of procedure logic
--
-- Initialize output parameters with defaults
--
VALUES (SQLSTATE,SQLCODE, SQLERRMC) INTO p_sqlstate, p_sqlcode,
p_sqlerrmc;
--
-- Set up SQL to unknown table
--
SET v_dynstmt = 'INSERT INTO DBAIR001.T0010TEST (COL1) VALUES
(1)';
PREPARE v_prepstmt FROM v_dynstmt;
EXECUTE v_prepstmt;
end#

This doesn't work however -

bash-2.05b$ db2 "call dbair001.sp001testerr(?,?,?)"

Value of output parameters
--------------------------
Parameter Name : P_SQLSTATE
Parameter Value : 42704

Parameter Name : P_SQLCODE
Parameter Value : -204

Parameter Name : P_SQLERRMC
Parameter Value : -

Return Status = 0

Any idea what I'm doing wrong ?

Thanks

Phil Nelson

Aug 23 '06 #1
2 3683
Use the GET_DIAGNOSTICS statement:
http://publib.boulder.ibm.com/infoce...n/r0005647.htm

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 23 '06 #2
Serge Rielau wrote:
Use the GET_DIAGNOSTICS statement:
http://publib.boulder.ibm.com/infoce...n/r0005647.htm
>
Cheers
Serge
Thanks Serge : I should have remembered that !!!

Phil
Aug 23 '06 #3

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

Similar topics

3
by: Vipul Pathak | last post by:
Hello Friends ! I have the Following Code, that Executes a Stored Procedure and Attempt to read a Returned Integer Value from the StoredProc. But It gives Error ... ADODB.Command (0x800A0BB9)...
3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
4
by: Chris Auer | last post by:
What I am looking to do is use a complicated stored procedure to get data for me while in another stored procedure. Its like a view, but a view you can't pass parameters to. In essence I would...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
6
by: Uday | last post by:
Hi everyone, I have a ASP page that triggers a db-side stored procedure. At the end of the procedure, it spits out a log file, that this ASP page reads and displays for the users. But the...
1
by: sshankar | last post by:
Hi, New to Stored procedure. Basically just installed DB2 v8.1.0.36 Was trying to build a stored procedure.. It is giving following error.. Looks like some error related to configuration...
2
by: jed | last post by:
I have created a stored procedure in SQLExpress management.I need to retrieve a numeric value that the stored procedure creates and use it in a C# application.Please help thanks. USE GO /******...
2
by: Andrew Cooper | last post by:
Greetings, I'm creating a website using ASP.NET. In creating my DAL I've got a Table Adapter that I've set up to use an existing Stored Procedure from an SQL Server 2000 database. 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: 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
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...
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
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
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...
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.