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 » how to select and update

Post new topic  Reply to topic
 how to select and update « View previous topic :: View next topic » 
Author Message
terminator_xyz
PostPosted: Mon Nov 17, 2014 1:15 pm    Post subject: how to select and update Reply with quote

Novice

Joined: 29 Jul 2014
Posts: 15

Hi tested below code with multiple update statement, but nothing worked.

1. i am doing a select query
2. then i need to update all the rows which i selected in step 1

step 1 is working, but step 2 is not working. Can anyone please help me?


DECLARE cQuery CHARACTER;
SET cQuery='SELECT * FROM '||ext_SchemaName||'.'||ext_Header||' JOIN '|| ext_SchemaName||'.'||ext_Detail||' ON HORD = DORD WHERE HCON = ?'
SET OutputRoot.XMLNSC.TEST[] = PASSTHRU(cQuery,'001');

SET Environment.Variables.ORD[]=SELECT MM.ORD FROM OutputRoot.XMLNSC.TEST[] AS MM;
DECLARE cQuery1 CHARACTER;
SET cQuery1='UPDATE '||ext_SchemaName||'.'||ext_Header||' AS S SET BAT=? WHERE S.ORD IN (?)';
PASSTHRU(cQuery1,'20141117',Environment.Variables.ORD[]);
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Nov 17, 2014 1:29 pm    Post subject: Re: how to select and update Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

terminator_xyz wrote:
step 1 is working, but step 2 is not working. Can anyone please help me?


Define "not working"; returns SQL code, doesn't update any rows, what?


terminator_xyz wrote:
SET Environment.Variables.ORD[]=SELECT MM.ORD FROM OutputRoot.XMLNSC.TEST[] AS MM;
DECLARE cQuery1 CHARACTER;
SET cQuery1='UPDATE '||ext_SchemaName||'.'||ext_Header||' AS S SET BAT=? WHERE S.ORD IN (?)';
PASSTHRU(cQuery1,'20141117',Environment.Variables.ORD[]);


Can you pass a WMB tree variable to a database IN clause that expects a string?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
terminator_xyz
PostPosted: Mon Nov 17, 2014 1:46 pm    Post subject: Reply with quote

Novice

Joined: 29 Jul 2014
Posts: 15

"not working" means the table is not getting updated

http://www-01.ibm.com/support/knowledgecenter/SSKM8N_7.0.0/com.ibm.etools.mft.doc/ak01045_.htm

in above link, it is mentionedESQL IN operator accepts a list attribute.

SET OutputRoot.XMLNSC.Top.Result3 = 42 IN(
SELECT A FROM InputRoot.XMLNSC.Top.a[] AS A);


any help? else, do i need concatenate MM.ORD of the result with , and pass it update passthru?
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Nov 17, 2014 1:51 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

terminator_xyz wrote:
"not working" means the table is not getting updated


Ok

terminator_xyz wrote:
in above link, it is mentionedESQL IN operator accepts a list attribute.


Yes, but you're not using it in ESQL are you? You're passing it via the PASSTHRU function to the database.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
terminator_xyz
PostPosted: Mon Nov 17, 2014 1:53 pm    Post subject: Reply with quote

Novice

Joined: 29 Jul 2014
Posts: 15

I am not using in ESQL. You are correct

Apart from concatenating (to create like '123','456','111'), do you have any better solution to update the table?
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Nov 18, 2014 5:54 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

terminator_xyz wrote:
Apart from concatenating (to create like '123','456','111'), do you have any better solution to update the table?


You could itterate through the values:
Code:

PASSTHRU(cQuery1,'20141117',Environment.Variables.ORD[1]);
PASSTHRU(cQuery1,'20141117',Environment.Variables.ORD[2]);
PASSTHRU(cQuery1,'20141117',Environment.Variables.ORD[3]);


(obviously using variable or other method, I've shown the absolute indexes just for clarity)

The question is do you want the overhead of multiple update statements, or do you want the overhead of string processing (which is not WMB's strong suit) in the form of concatenation?

The answer to that will be based on futher questions including but not limited to:

- how many rows are in the database table?
- where are the indexes?
- how many elements will you likely be iterating through?
- could you safely rewrite the flow to issue multiple PASSTHRU (i.e. parallel process) without locking the database?
- what's the SLA of this process?

For example (and only for example) if you only have 3 elements as you show, it's probably better to concatenate. If you have 30, it's probably better to itterate.

Pick a method and go for it. You might want to consider performance testing both methods against production sized data with a small test harness flow to help you decide. You may well see no siginficant difference with small test databases.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » how to select and update
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.