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 » Referencing multiple instances of an element in ESQL

Post new topic  Reply to topic
 Referencing multiple instances of an element in ESQL « View previous topic :: View next topic » 
Author Message
cloucas
PostPosted: Thu May 04, 2006 5:15 am    Post subject: Referencing multiple instances of an element in ESQL Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

I have a message set that conatins a message whose type consists of a header and a body. The body is a complex type and is composed of three different complex types, such that:

[Header][[Type1][Type2][Type3]]

Type2 above is a field delimited type that can have one or more occurences of a pair of elements, such that:

[AccountNo][Balance], each element is ofcourse preceded by its delimiter.

So for instance, if an account holder has three accounts, the message would look like:

[Header][[Type1][(Account1)(Balance1)(Account2)(Balance2)(Account3)(Balance3)][Type3]]

The number of accounts is different from accountholder to accountholder and is thus not fixed.

My question is how to reference each of these instances of accounts in the message from my ESQL (i.e. is there an 'array-like' reference I can use?).

Thanks in advance


Chris
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu May 04, 2006 5:22 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi cloucas,

Well described problem

You should search for REFERENCE TO, MOVE, NEXTSIBLING...search in the forum or in the ESQL pdf.

Regards.
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Thu May 04, 2006 5:29 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

In fact, it's not an "array-like" syntax. It's so much exactly like an array syntax that people get confused and think it IS an array.

Set OutputRoot.MRM.Type1.Account[3] = "Account3";
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sirsi
PostPosted: Thu May 04, 2006 7:54 am    Post subject: Reply with quote

Disciple

Joined: 11 Mar 2005
Posts: 177

shouldnt this be

Set OutputRoot.MRM.Type2.Account[3] = "Account3";

instead of

Set OutputRoot.MRM.Type1.Account[3] = "Account3";

considering Account details occur inside Type2
Back to top
View user's profile Send private message
cloucas
PostPosted: Thu May 04, 2006 8:51 pm    Post subject: Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

OK Guys

Thanks very much for your help....any ideas on how to reference the number of elements in the array? My idea is to loop through all elements...is there a "FOR EACH...." loop in ESQL or must I loop through using FOR loop?

Thanks

Chris
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu May 04, 2006 9:12 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi cloucas,

Use what ever you can get it working with...dont your FOR else u'll have to find an integer i and store all available child elements etc....

U can use a WHILE LASTMOVE(reference) with a MOVE reference NEXTSIBLING....

Regards.
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Fri May 05, 2006 2:32 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

The right way to do this would be to change your message set definition and create a header level:
MRM-type1
-type2 accounts(group level)
-account(=subtype 2) ,0, unbounded
-type3

And address them by OutputRoot.MRM.type2.*[]
This way you can do a cardinality on them and really treat them as an array.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Fri May 05, 2006 6:44 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

fjb_saper: Not sure what you mean.
- cloucas's logical model sounds fine to me - why should he change it?
- CARDINALITY works on any node in the message tree - it just returns the number of child nodes. This is independent of the message set ( if any ) which the parser used to produce the tree.
- your syntax 'OutputRoot.MRM.type2.*[]' looks strange. Why the anonymous field reference? Surely cloucas wants paths like 'Set OutputRoot.MRM.Type2.Account[3]' and 'Set OutputRoot.MRM.Type2.Balance[3]'

I've probably misunderstood what you were saying, but I'm posting this in case anyone else gets confused.
Back to top
View user's profile Send private message
sirsi
PostPosted: Fri May 05, 2006 7:17 am    Post subject: Reply with quote

Disciple

Joined: 11 Mar 2005
Posts: 177

i have another question... which is the most efficient way of looping through multiple occurrences... i remember reading somewhere that using "WHILE LASTMOVE(reference)" method should be the efficient one...
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri May 05, 2006 8:35 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

sirsi wrote:
I remember reading somewhere that using "WHILE LASTMOVE(reference)" method should be the efficient one...

It certainly should be. If it isn't, you can probably open a PMR.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri May 05, 2006 9:01 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

kimbert wrote:
fjb_saper: Not sure what you mean.
- cloucas's logical model sounds fine to me - why should he change it?
- CARDINALITY works on any node in the message tree - it just returns the number of child nodes. This is independent of the message set ( if any ) which the parser used to produce the tree.
- your syntax 'OutputRoot.MRM.type2.*[]' looks strange. Why the anonymous field reference? Surely cloucas wants paths like 'Set OutputRoot.MRM.Type2.Account[3]' and 'Set OutputRoot.MRM.Type2.Balance[3]'

I've probably misunderstood what you were saying, but I'm posting this in case anyone else gets confused.


The problem from what I understand is the way he defined his message set.
By not defining a header level for his occurs he actually gets a flat recurrence:
- type1
- type2
- type2
- type2 n
- type 3

This makes manipulations very difficult as it is not easy to determine the number of occurrences of type2

By defining his structure a little bit differently (the data on the wire may still look the same) he gets some advantage
-type1
-type2 - child(0, unbounded)
-type3
and can access it directly in a true array style :
OutputRoot.MRM.type2.child[n]
Declare k integer cardinality (OutputRoot.MRM.type2.*[]);
Otherwise there is a hard time getting the number of occurrences as
declare k integer cardinality(OutputRoot.MRM.*[]) will also return type1 and type3 occurrences...

Of course you could try a select to determine the cardinality but if you have to manipulate the data the other way makes it just plain more simple. (XML rule -- always have a header level for the items of a collection...)

Hope this clarifies a bit
Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Referencing multiple instances of an element in ESQL
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.