|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Odbc SQL Server: RAISEERROR |
« View previous topic :: View next topic » |
Author |
Message
|
raphael.silva |
Posted: Wed Apr 13, 2011 4:42 am Post subject: Odbc SQL Server: RAISEERROR |
|
|
Newbie
Joined: 28 Mar 2011 Posts: 8
|
Hi!
I'm calling a MS SqlServer 2008 stored procedure through ESQL, using datadirect Odbc.
The procedure does some validations and eventualy it raises an exception through the RAISEERROR instruction.
The problem is that the Odbc doesn't throw exceptions, like jdbc does for example. So my ESQL code is not able to detect the problem that occured at the stored procedure, and continues as if it was successful.
How can I capture the SqlServer RAISEERROR in my ESQL code?
Thanks! |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 13, 2011 5:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Have you wrapped the call to the stored procedure in a DECLARE HANDLER block?
Have you examined the SQLSTATE, SQLCODE, SQLERRORTEXT and SQLNATIVEERROR values? |
|
Back to top |
|
 |
raphael.silva |
Posted: Wed Apr 13, 2011 6:27 am Post subject: |
|
|
Newbie
Joined: 28 Mar 2011 Posts: 8
|
Yes I did it like this:
DECLARE EXIT HANDLER FOR SQLSTATE LIKE '%'
BEGIN
SET Environment.h.SQLSTATE = SQLSTATE;
SET Environment.h.SQLCODE = SQLCODE;
SET Environment.h.SQLERRORTEXT = SQLERRORTEXT;
SET Environment.h.SQLNATIVEERROR = SQLNATIVEERROR ;
END;
But this code doesnt seem to be executed. |
|
Back to top |
|
 |
raphael.silva |
Posted: Wed Apr 13, 2011 8:45 am Post subject: |
|
|
Newbie
Joined: 28 Mar 2011 Posts: 8
|
I made some tests.
I used PASSTHRU statement to call the procedure.
That way, my handler code was reached.
I have some doubts. Why does it works for PASSTHRU but it doesn't calling the declared stored procedure?
Cenario1)
My procedure is declared like this:
CREATE PROCEDURE InsertContract(IN idContract CHARACTER)
LANGUAGE DATABASE
EXTERNAL NAME "TKTWSW.EAI_ContractBackOffice";
And when i called it: CALL InsertContract('1234');
The procedure is called but the error is not captured by the ESQL handler.
Cenario2)
I call the procedure using PASSTHRU:
PASSTHRU('EXEC [TKTWSW].[EAI_ContractBackOffice] ''1234'' ');
The procedure is called and the error is captured by the handler.
Am I missing something here?
Is there an explanation for these different behaviors calling the stored procedure? |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|