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 and detecting SQL stmt errors

Post new topic  Reply to topic
 ESQL and detecting SQL stmt errors « View previous topic :: View next topic » 
Author Message
Gideon
PostPosted: Thu Nov 03, 2011 12:55 pm    Post subject: ESQL and detecting SQL stmt errors Reply with quote

Chevalier

Joined: 18 Aug 2009
Posts: 403

I am intentionally trying to insert on top of a previously entered
row to see how to handle exceptions

I sent the following command in ESQL

Code:
   SET cmd = 'INSERT into db2inst1.catalog (pid,price) values (1,1)';
   SET OutputLocalEnvironment.Variables.Ret = PASSTHRU(cmd);

This works the first time, but the second time through the code
throughs an exception, and goes out the Failure terminal, where I
can see it in the Trace node

When I UN-CHECK the "Throuw exception on Database error", the flow
no longer throws an error, the output routes through the "Out" terminal

The first time through (on an empty table, successfull insert, the
trace shows:

Code:
--- Local Env:( ['MQROOT' : 0x1f5d26c0]
  (0x01000000:Name):Variables =
)^M
--- Env:^M
--- Excpt:^M
--------------------------

On the second time through (bad insert cmd trying to overwrite a record),
it agains goes through the 'out' terminal, and the trace node shows:


Code:
--- Local Env:^M
--- Env:^M
--- Excpt:^M
--------------------------

In the first case I see a local env, but not the "Ret" I was trying to
write to

In the second case I do not see a local env of any sort

SInce both cases do not show a RET, I can not test ret inside of ESQL to
determine if the INSERT completed successfully

How can I do this ?
Back to top
View user's profile Send private message Send e-mail
harish_td
PostPosted: Thu Nov 03, 2011 3:27 pm    Post subject: Reply with quote

Master

Joined: 13 Feb 2006
Posts: 236

Try SQLCODE

http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ak17960_.htm
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ak05840_.htm
Back to top
View user's profile Send private message Yahoo Messenger
inMo
PostPosted: Mon Nov 07, 2011 11:30 am    Post subject: Reply with quote

Master

Joined: 27 Jun 2009
Posts: 216
Location: NY

The concept is to try the action , then check the return codes. I imagine the return code(s) are discussed in the previous post's links, so I won't discuss them here. Can you define the use case that is driving you to uncheck the "Throw exception on Database error" option ? (There are valid reasons, hence the option, just curious what yours is?)
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Nov 07, 2011 12:08 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

One case I have encounteres a few times is where you don't care if an insert causes a primary key violation (eg, a duplicate row).
As suggested, you can disable the automatic throwing of an exception and generate your own if needed. This gives you the chance to add some extra details to the exception.

For example, adding the SQL Command that caused the exception.
OR
Adding some data to help with finding where the exception took place.

I actually prefer this to letting the exception to be thrown automatically.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
inMo
PostPosted: Mon Nov 07, 2011 12:54 pm    Post subject: Reply with quote

Master

Joined: 27 Jun 2009
Posts: 216
Location: NY

Yes. Value added processing on error condition can prove quite helpful. The ideas expressed in the previous post can add meaningful value, especially when tied to a comprehensive exception handling strategy. My general concern was the idea that turning off the throw errors option could have been stated as the "I'll take full responsibility for handling my errors" option. Unfortuenately, not everyone that agrees to this condition actually does.
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 » ESQL and detecting SQL stmt errors
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.