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 help

Post new topic  Reply to topic
 ESQL help « View previous topic :: View next topic » 
Author Message
rkford11
PostPosted: Tue Jan 25, 2005 10:20 am    Post subject: ESQL help Reply with quote

Partisan

Joined: 06 Jun 2004
Posts: 316

I have to update a record if it exists or insert if it does not.
i am comparing the incoming message with a column data in table, if its same then update else insert.
here is my esql

set M = THE(SELECT ITEM col1 from Database.ABC as X WHERE X.COL1 = InputRoot.XML.XYZ.A)

IF M = InputRoot.XML.XYZ.A THEN

UPDATE Database.ABC as c
SET col2 = InputRoot.XML.XYZ.B
col3 = InputRoot.XML.XYZ.C

ELSE

INSERT INTO Database.ABC(col1, col2, col3) values (InputRoot.XML.XYZ.A,InputRoot.XML.XYZ.B,InputRoot.XML.XYZ.C);

END IF;

Please correct my ESQL.

Thanks
Back to top
View user's profile Send private message
waugh
PostPosted: Tue Jan 25, 2005 10:40 am    Post subject: Reply with quote

Master

Joined: 19 Feb 2004
Posts: 225

read your select statement into environment tree.

do CARDINALITY function on your environment tree.

then if the CARDINALITY returned >= 1 then

do update

else insert

CARDINALITY function usage exaplained in ESQL Guide...
Back to top
View user's profile Send private message
JT
PostPosted: Tue Jan 25, 2005 11:00 am    Post subject: Reply with quote

Padawan

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

Quote:
Please correct my ESQL

What's the error?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 25, 2005 11:50 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Does UPDATE fail if the record doesn't exist?

Does it return an SQLERRORCODE in that case, that can be checked?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
rkford11
PostPosted: Tue Jan 25, 2005 9:17 pm    Post subject: Reply with quote

Partisan

Joined: 06 Jun 2004
Posts: 316

jefflowrey wrote:
Does UPDATE fail if the record doesn't exist?

Does it return an SQLERRORCODE in that case, that can be checked?


Thanks to all of you. i was making mistake in my logic and u r suggestions helped me to correct it.
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 help
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.