ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Odbc SQL Server: RAISEERROR

Post new topic  Reply to topic
 Odbc SQL Server: RAISEERROR « View previous topic :: View next topic » 
Author Message
raphael.silva
PostPosted: Wed Apr 13, 2011 4:42 am    Post subject: Odbc SQL Server: RAISEERROR Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Wed Apr 13, 2011 5:02 am    Post subject: Reply with quote

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
View user's profile Send private message
raphael.silva
PostPosted: Wed Apr 13, 2011 6:27 am    Post subject: Reply with quote

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
View user's profile Send private message
raphael.silva
PostPosted: Wed Apr 13, 2011 8:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Odbc SQL Server: RAISEERROR
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.