|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
ESQL help |
« View previous topic :: View next topic » |
Author |
Message
|
rkford11 |
Posted: Tue Jan 25, 2005 10:20 am Post subject: ESQL help |
|
|
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 |
|
 |
waugh |
Posted: Tue Jan 25, 2005 10:40 am Post subject: |
|
|
 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 |
|
 |
JT |
Posted: Tue Jan 25, 2005 11:00 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
Please correct my ESQL |
What's the error? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 25, 2005 11:50 am Post subject: |
|
|
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 |
|
 |
rkford11 |
Posted: Tue Jan 25, 2005 9:17 pm Post subject: |
|
|
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 |
|
 |
|
|
 |
|
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
|
|
|
|