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 » ESQL - Checking SQLSTATE, SQLCODE !!

Post new topic  Reply to topic
 ESQL - Checking SQLSTATE, SQLCODE !! « View previous topic :: View next topic » 
Author Message
neo_revolution
PostPosted: Mon Jul 12, 2004 6:40 am    Post subject: ESQL - Checking SQLSTATE, SQLCODE !! Reply with quote

Voyager

Joined: 21 Oct 2003
Posts: 80
Location: NJ

Hello All,

I am using

PASSTHRU('DELETE FROM LOG WHERE DATE(TMSTP) < ? ', myDate);

Suppose there are no records earlier than 'myDate' we will get some SQLWarning.

I am thinking how to catch the SQLCODE and SQLSTATE using ESQL ?

I unchecked 'Throw Exception on Database errors' in the compute node... even I am getting the default values for the SQLSTATE and SQLCODE.

I am working with broker deployed on OS/390 and DB2 (OS/390).

Thanks.
Back to top
View user's profile Send private message Yahoo Messenger
CoolDude
PostPosted: Mon Jul 12, 2004 12:49 pm    Post subject: Reply with quote

Apprentice

Joined: 17 Jan 2004
Posts: 39

You can capture the sql codes in the environment variables like this

CREATE FIELD Environment.Variables.SQLCodes;
DECLARE SQLC REFERENCE TO Environment.Variables.SQLCodes;

SET SQLC.SQLSTATE = SQLSTATE;
SET SQLC.SQLCODE = SQLCODE;
and so on.

In order to do this you need to uncheck the "Throw Exception on Database errors" condition in the Advanced pane of the compute node.

once you capture this information you can

IF (SQLC.SQLSTATE <> 0) THEN
THROW USER EXCEPTION;
END IF;
_________________
Correct Me from Wrong . If i am correct Appreciate Me
Back to top
View user's profile Send private message
JT
PostPosted: Mon Jul 12, 2004 2:02 pm    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

neo_revolution wrote:
Suppose there are no records earlier than 'myDate' we will get some SQLWarning.
Not sure if there's another SQL field that denotes no rows were deleted, but the SQLCODE will be zero.

CoolDude wrote:
once you capture this information you can

IF (SQLC.SQLSTATE <> 0) THEN
THROW USER EXCEPTION;
END IF;

It's not necessary to capture the SQL error values prior to interrogating them. You may wish to preserve the values only when an error is detected.
Code:
PASSTHRU('DELETE FROM LOG WHERE DATE(TMSTP) < ? ', myDate);
IF (SQLCODE <> 0) THEN
   CREATE FIELD Environment.Variables.SQLCodes;
   DECLARE SQLC REFERENCE TO Environment.Variables.SQLCodes;
   SET SQLC.SQLSTATE = SQLSTATE;
   SET SQLC.SQLCODE = SQLCODE;
 END IF;
Back to top
View user's profile Send private message
kirani
PostPosted: Mon Jul 12, 2004 4:22 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Did you look at the value in SQLSTATE variable?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
JT
PostPosted: Tue Jul 13, 2004 6:18 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Quote:
Not sure if there's another SQL field that denotes no rows were deleted, but the SQLCODE will be zero.

............. the SQLSTATE and SQLNATIVEERROR variables were also zero.
Back to top
View user's profile Send private message
neo_revolution
PostPosted: Tue Jul 13, 2004 6:21 am    Post subject: Reply with quote

Voyager

Joined: 21 Oct 2003
Posts: 80
Location: NJ

Hi Kiran,

I gave the table name wrong intentionally and I got SQLSTATE = 42S22 and SQLCODE = -1

But if I see SQLERRORTEXT, SQLCODE = -206 and SQLSTATE = 42703,

Why WMQI SQLSTATE is different from DB2 SQLSTATE? How can I correlate them?

Thanks.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL - Checking SQLSTATE, SQLCODE !!
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.