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 » Repeating element index values

Post new topic  Reply to topic Goto page 1, 2  Next
 Repeating element index values « View previous topic :: View next topic » 
Author Message
adubya
PostPosted: Tue Aug 30, 2011 4:50 am    Post subject: Repeating element index values Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Hi,

I'm getting myself confused over how ESQL accesses repeating occurrences of an element in a message tree. Specifically the index value of the "first" element. My confusion was started by reading the following WMB7 technote:-

http://www-01.ibm.com/support/docview.wss?uid=swg21509339&myns=swgws&mynp=OCSSKM8N&mync=R

Now I've always taken (WMB) index values to start at 1, not zero. But when I check some of our WMB6 code which is due to be ported over to WMB7 soon then I see some examples of hardcoded element[0] type constructs. So according to the technote then this will generate an error in WMB7 unless the env. variable is set to get broker to revert to accepting zero as the first element.

So, my question is, in WMB6 ESQL are element[0] and element[1] basically the same reference if either is the first expression which causes the message tree to be parsed ? i.e. will WMB6 treat index value 0 the same as index value 1 when initially parsing the tree.

Hope that makes sense ?

Cheers,

Andy.
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Tue Aug 30, 2011 5:12 am    Post subject: Reply with quote

Jedi Knight

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

In WMB 7, the first ESQL element is [1]. If you try [0], you get an error. IDKY, because in computer science, the first element has traditionally been zero.
_________________
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
adubya
PostPosted: Tue Aug 30, 2011 5:19 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

lancelotlinc wrote:
In WMB 7, the first ESQL element is [1]. If you try [0], you get an error. IDKY, because in computer science, the first element has traditionally been zero.


Yup, completely agree. What I'm trying to understand is the WMB6 behaviour when an index value of zero is used vs an index value of one.
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Tue Aug 30, 2011 5:24 am    Post subject: Reply with quote

Jedi Knight

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

adubya wrote:
lancelotlinc wrote:
In WMB 7, the first ESQL element is [1]. If you try [0], you get an error. IDKY, because in computer science, the first element has traditionally been zero.


Yup, completely agree. What I'm trying to understand is the WMB6 behaviour when an index value of zero is used vs an index value of one.


In WMB6, the element zero is the first element and the element one is the second element. There are not two first elements.
_________________
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
adubya
PostPosted: Tue Aug 30, 2011 5:29 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

lancelotlinc wrote:
In WMB6, the element zero is the first element and the element one is the second element. There are not two first elements.


Now, that is the question Looking at my WMB6 code, 99% of it uses an index value of 1 to access the first element. If your statement is correct then all that code is incorrect, which I'm pretty sure it isn't. Are you 100% sure of your statement ?

Perhaps you're right if you initially access the message structure using an index of zero and WMB6 will take this as being the first element with any subsequent index access of one giving the second element and so on. BUT if the first access to the message structure uses index value of one this this also maps to the first element with subsequent index of two mapping to the second value etc.


Last edited by adubya on Tue Aug 30, 2011 5:37 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Tue Aug 30, 2011 5:32 am    Post subject: Reply with quote

Jedi Knight

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

Since you are migrating, the point is moot. However, curiosity killed the cat, and I'm just as curious as you are. You may like to open a PMR to see. If you get official word, please post back the IBM response.
_________________
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
mqjeff
PostPosted: Tue Aug 30, 2011 5:33 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

lancelotlinc wrote:
adubya wrote:
lancelotlinc wrote:
In WMB 7, the first ESQL element is [1]. If you try [0], you get an error. IDKY, because in computer science, the first element has traditionally been zero.


Yup, completely agree. What I'm trying to understand is the WMB6 behaviour when an index value of zero is used vs an index value of one.


In WMB6, the element zero is the first element and the element one is the second element. There are not two first elements.


I'm gonna have to disagree with your police work there, Lou.
Fields are numbered from the first, starting at one.
Back to top
View user's profile Send private message
adubya
PostPosted: Tue Aug 30, 2011 5:35 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

lancelotlinc wrote:
Since you are migrating, the point is moot. However, curiosity killed the cat, and I'm just as curious as you are. You may like to open a PMR to see. If you get official word, please post back the IBM response.


Unfortunately the point isn't moot as I need to port all of the code including the small amount which uses index value zero as the first element. So that will break in WMB7 unless I either:-

a) Change the code to comply with the technote linked above.
or
b) Set the environment variable which reverts back to WMB6 behaviour when using index values.

I'd rather not go for option b) as that's just a sticking plaster but I need to understand how the indexing is working in WMB6 in order to work out how much code is affected.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Tue Aug 30, 2011 5:40 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

As far as I know, ESQL has always been a 1-indexed language rather than a 0-indexed language.

The current iteration of the Broker v6 Information Center indicates this as well, as shown by the link I posted above.

So it's not clear to me where the notion of using a 0 index came from, or why there is a technote about this change in behavior that seems to suggest that ESQL was ever 0-indexed.
Back to top
View user's profile Send private message
adubya
PostPosted: Tue Aug 30, 2011 6:05 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

mqjeff wrote:
As far as I know, ESQL has always been a 1-indexed language rather than a 0-indexed language.

The current iteration of the Broker v6 Information Center indicates this as well, as shown by the link I posted above.

So it's not clear to me where the notion of using a 0 index came from, or why there is a technote about this change in behavior that seems to suggest that ESQL was ever 0-indexed.


Yes, hence my confusion! As I mentioned above, we do have some WMB6 code that uses element[0] type constructs and I have no reason to believe that it doesn't work. I can only assume that WMB6 (and earlier versions) allowed index values of zero and treated them as the first element.
Back to top
View user's profile Send private message Send e-mail
adubya
PostPosted: Tue Aug 30, 2011 7:16 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Right, spoken to a "guru" and apparently this is the score.

In WMB6 there was a bug when repeating elements were accessed using a literal index value of zero. WMB6 would accept the index and not throw an error BUT the resultant element accessed would actually be the LAST element in the repeating group!
If a variable were used as the index and the variable were initialised with a value of zero then a runtime error would be thrown when the index were used to access the message structure.

That's a relief as I've only got two ESQL lines which use a literal index value of zero and so will be easy to port.
Back to top
View user's profile Send private message Send e-mail
mgk
PostPosted: Tue Aug 30, 2011 7:44 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

OK. I'll try an explain the reason for the technote and the problem it fixes.

As stated above, in ESQL arrays are 1 based. And in you access an array using a variable as an index, you will get an exception if your variable evaluates to zero:

Code:
DECLARE x INTEGER 0;
SET myVar = OutputRoot.XMLNSC.Top.A.B[x]; -- exception here


However, there was a problem discovered was if a literal 0 was used:

Code:

SET myVar = OutputRoot.XMLNSC.Top.A.B[0]; -- no exception here before V7


Now using a literal 0 did not cause a visible problem if there was only one element being indexed (B in this case), and in this case an index of 1 and 0 do indeed resolve to the same element. However, there was a problem if there was more that one element being indexed. If the message structure was:

Code:
<Top>
  <A>
    <B>b1</B>
    <B>b2</B>
    <B>b3</B>
  </A>
</Top>   


Where there is more than one B, then this code:

Code:
SET myVar = OutputRoot.XMLNSC.Top.A.B[0];


Does not return the first B (b1), but rather the last B (b3), which is not the expected behaviour at all. Consquently this was fixed in V7, and the tech note was written.

I hope this helps explain things a little better.

Kind regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
adubya
PostPosted: Tue Aug 30, 2011 8:12 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Thanks for the confirmation! The technote could have been worded so much better though, it creates confusion rather than clarifying the issue IMO.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Tue Aug 30, 2011 8:16 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

adubya wrote:
Thanks for the confirmation! The technote could have been worded so much better though, it creates confusion rather than clarifying the issue IMO.


That's what the feedback section at the bottom of the page is for...
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Aug 30, 2011 8:34 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Thanks mgk - I thought that was probably the case.

For future readers of this thread: The message broker development team take *great* pains not to introduce incompatible changes in behavior between one version and the next. We call that 'breaking the user', and we have large test suites aimed at preventing it. So my first thought when reading the first post was "this is very unlikely to be true". An accidental change in the meaning of some node property might occasionally slip through. But changing the base index of *all* arrays in ESQL? Not a chance that it would ever make it out of the door.
So I'm relieved so see that my instincts were correct. It's a defect fix which might break a small subset of users who are using illegal ESQL.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Repeating element index values
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.