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 all leaf node from xml

Post new topic  Reply to topic
 How to select all leaf node from xml « View previous topic :: View next topic » 
Author Message
zhumingvictor
PostPosted: Mon Jul 29, 2013 7:29 am    Post subject: How to select all leaf node from xml Reply with quote

Novice

Joined: 10 May 2013
Posts: 17

Hi I am trying to do:

SET MY_COUNT= (SELECT COUNT(*)
FROM InputRoot.XMLNSC.myroot.batches.batch[].transactions.transaction[] as trans
WHERE trans.transType = 'ABC');

But I got Syntax error : cannot specify '[]' in the middle of a field reference.

The list specifier ('[]') can only be used at the end of a field reference.


Anybody know how I can correct this?

Thanks.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Jul 29, 2013 7:38 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Set a reference. InputRoot.XMLNSC.myroot.batches

Then iterate through, selecting batch[I].transactions.transaction[J].

Its basically what you were trying to do in one-shot, split up into two steps.

Good luck.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
zhumingvictor
PostPosted: Mon Jul 29, 2013 7:39 am    Post subject: Reply with quote

Novice

Joined: 10 May 2013
Posts: 17

lancelotlinc wrote:
Set a reference. InputRoot.XMLNSC.myroot.batches

Then iterate through, selecting batch[I].transactions.transaction[J].

Its basically what you were trying to do in one-shot, split up into two steps.

Good luck.


No way to do it without looping through?
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Jul 29, 2013 7:45 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Looping is not so bad, when you use REFERENCE. Try it out.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
dogorsy
PostPosted: Mon Jul 29, 2013 8:35 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

you need to use nested selects and then you don't need to loop.

something like

SET MY_COUNT= SELECT
( SELECT COUNT(*)
FROM I.transactions.transaction[] as trans
WHERE trans.transType = 'ABC')
from InputRoot.XMLNSC.myroot.batches.batch[] as I;

in terms of performance it is way faster than looping.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Jul 29, 2013 8:54 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

dogorsy wrote:
in terms of performance it is way faster than looping.


Absolutely korek. Unless s/he needs to loop anyway for other data capture.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
digoshc
PostPosted: Mon Jul 29, 2013 9:35 am    Post subject: Reply with quote

Apprentice

Joined: 11 Jul 2013
Posts: 25

Hi, got a question. Do you guys could give a brief explanation why nested selects would be faster than a loop, please? Thank you.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Mon Jul 29, 2013 9:39 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

it has been performance tested.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jul 29, 2013 11:42 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Do you guys could give a brief explanation why nested selects would be faster than a loop, please?
I didn't say that, and I wouldn't. It might depend on what you're SELECTing from and how complex the SELECT statements are.
As always, the performance of your message flow is your responsibility, so you should put a performance test framework in place and do some experiments.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
zhumingvictor
PostPosted: Mon Jul 29, 2013 12:00 pm    Post subject: Reply with quote

Novice

Joined: 10 May 2013
Posts: 17

dogorsy wrote:
you need to use nested selects and then you don't need to loop.

something like

SET MY_COUNT= SELECT
( SELECT COUNT(*)
FROM I.transactions.transaction[] as trans
WHERE trans.transType = 'ABC')
from InputRoot.XMLNSC.myroot.batches.batch[] as I;

in terms of performance it is way faster than looping.

It works! I don't need each item so nested query is good. Thanks to all of you.
Back to top
View user's profile Send private message
digoshc
PostPosted: Mon Jul 29, 2013 12:36 pm    Post subject: Reply with quote

Apprentice

Joined: 11 Jul 2013
Posts: 25

@kimbert: I agree. Overall, I believe ESQL might have a better performance than others transformations approaches since it's a DSL built specifically to handle message trees, but a performance test would help to prove this hypothesis.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Mon Jul 29, 2013 10:03 pm    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

zhumingvictor wrote:
dogorsy wrote:
you need to use nested selects and then you don't need to loop.

something like

SET MY_COUNT= SELECT
( SELECT COUNT(*)
FROM I.transactions.transaction[] as trans
WHERE trans.transType = 'ABC')
from InputRoot.XMLNSC.myroot.batches.batch[] as I;

in terms of performance it is way faster than looping.

It works! I don't need each item so nested query is good. Thanks to all of you.


Good !. Even if you do need items from the message, you can code a complex nested SELECT.
for more info, see
"Transforming a complex message" topic in the infocenter
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 all leaf node from xml
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.