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 count by using cardinality function

Post new topic  Reply to topic
 How to count by using cardinality function « View previous topic :: View next topic » 
Author Message
sanupoju
PostPosted: Fri Sep 13, 2013 2:23 am    Post subject: How to count by using cardinality function Reply with quote

Newbie

Joined: 31 Jul 2012
Posts: 3

Hello All,

For example, CARDINALITY(InputRoot.XMLNSC.root.sub[].child[])

In the above statement, we have multiple sub tags and child tags, but I wanted to count no. of child tags present in all sub tags without using any loopings.
please correct me to handle this situation.


Last edited by sanupoju on Fri Sep 13, 2013 2:37 am; edited 1 time in total
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 13, 2013 2:29 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

No, you don't want to count these.

You want to solve the real requirement using some other method.
Back to top
View user's profile Send private message
sanupoju
PostPosted: Fri Sep 13, 2013 2:50 am    Post subject: Reply with quote

Newbie

Joined: 31 Jul 2012
Posts: 3

mqjeff wrote:
No, you don't want to count these.

You want to solve the real requirement using some other method.


Thanks for reply,
actually if the message is like below:
<custdetails>
<contactpoint>
<telinfo>..</telinfo>
<telinfo>..</telinfo>
</contactpoint>
<contactpoint>
<telinfo>..</telinfo>
</contactpoint>
<contactpoint>
<telinfo>..</telinfo>
<telinfo>..</telinfo>
</contactpoint>
</custdetails>
Pls note that xml structure was, custdetails-->contactpoint-->telinfo
How can we count the "telinfo" tag present in the above msg.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 13, 2013 2:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Why do you want to count them?
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Sep 13, 2013 3:18 am    Post subject: Reply with quote

Jedi Council

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

mqjeff wrote:
Why do you want to count them?


Because that's the requirement....


{ducks to avoid incoming <redacted>}
_________________
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
mqjeff
PostPosted: Fri Sep 13, 2013 4:55 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

smdavies99 wrote:
mqjeff wrote:
Why do you want to count them?


Because that's the requirement....


{ducks to avoid incoming <redacted>}


I'm holding up two fingers. It's a binary counting system, I assure you.

Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Sep 13, 2013 5:33 am    Post subject: Reply with quote

Grand High Poobah

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

sanupoju wrote:
How can we count the "telinfo" tag present in the above msg.


Why do you need to have a count of these elements?

What's wrong with looping?

And as indicated, don't say "because the requirement is to count these without looping".
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 13, 2013 5:38 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
And as indicated, don't say "because the requirement is to count these without looping".


And don't say "I need to know how many there are so I can loop over the count".
Back to top
View user's profile Send private message
Tibor
PostPosted: Fri Sep 13, 2013 6:34 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

You could try something like this:
Code:
DECLARE iCnt INTEGER 0;
FOR src AS InputRoot.XMLNSC.custdetails.contactpoint[] DO
     SET iCnt = iCnt + CARDINALITY(src.telinfo[]);
END FOR;

(not tested.)
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 13, 2013 6:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Tibor wrote:
You could try something like this:
Code:
DECLARE iCnt INTEGER 0;
FOR src AS InputRoot.XMLNSC.custdetails.contactpoint[] DO
     SET iCnt = iCnt + CARDINALITY(src.telinfo[]);
END FOR;

(not tested.)


And yet, that uses a loop.

And yet, so does CARDINALITY, even if it's under the covers.

I can think of another way to do this in ESQL without using an explicit loop.

But it still shouldn't be done in almost all cases.
Back to top
View user's profile Send private message
Tibor
PostPosted: Fri Sep 13, 2013 7:10 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

OK, I had not read the question carefully before I responded...
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 count by using cardinality function
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.