Author |
Message
|
Vinayak.Satapute |
Posted: Sun Aug 11, 2013 5:37 am Post subject: Array subscript error - ESQL Mapping (XML repeat tag) |
|
|
Acolyte
Joined: 20 Dec 2006 Posts: 70
|
Hi,
I have following code with "parameter" field as a repeated XML tag but I am getting array subscript error while I try to execute the code.
DECLARE I INTEGER 1;
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I].(XMLNSC.Attribute)name = 'enginePattern';
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I] = 'RTLTM';
SET I = I + 1;
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I].(XMLNSC.Attribute)name = 'tradingDate';
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I] = 'dd/mm/yy='||CAST(dDATE AS CHAR);
SET I = I + 1;
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I].(XMLNSC.Attribute)name = 'useLatestValidatedEngine';
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I] = 'true';
SET I = I +1;
SET OutputRoot.XMLNSC.ns1:request.ns1:parameters.ns1:parameter[I].(XMLNSC.Attribute)name = 'tickInput';
Appreciate your input here.
Thank You. |
|
Back to top |
|
|
dogorsy |
Posted: Sun Aug 11, 2013 5:48 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
you have not said what the value of dDATE is. if it is NULL, then the element will not be created and you will get the error described.
use current_date instead of dDATE to ensure your code works.
Also, if your elements are fixed, why use an index ?
just specify [1], [2] and [3]
AND ... as you can see it is a big AND, if you had run a user trace, you would've seen very quickly where the problem is. So I gave you a clue, next, if you still have problems, get a user trace and look at it. It is a good way of understanding what your code is doing. |
|
Back to top |
|
|
mqsiuser |
Posted: Sun Aug 11, 2013 8:51 am Post subject: |
|
|
Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
I have defined 3 rules (which you are breaking!)
Instead of these rules, I could have just said "Always use REFERENCEs!" (But just saying that wouldn't have been so spectacular )
Using REFERENCEs is the conclusion (which derives from the 3 rules). And probably it's easier to understand. It's a much clearer advice, but may lead to the question "why?". Why is answered by a good understanding of the product (Message Broker) and/or comparing user traces.
It also wouldn't have been clear enough about what (unnecessarily) harms performance. In your case it also harms the code-robustness:
The use of INDEX ([]) tends to lead to "array out of bounds exceptions", which you can avoid by JUST NOT USING INDEX! _________________ Just use REFERENCEs
Last edited by mqsiuser on Sun Aug 11, 2013 9:16 am; edited 1 time in total |
|
Back to top |
|
|
dogorsy |
Posted: Sun Aug 11, 2013 9:07 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
mqsiuser wrote: |
I have defined 3 rules (which you are breaking!)
Instead of these rules, I could have just said "Always use REFERENCEs!" (But just saying that wouldn't have been so spectacular )
Using REFERENCEs is the conclusion (which derives from the 3 rules). And probably it's easier to understand. It's a much clearer advice, but may lead to the question "why?". Why is answered by a good understanding of the product (Message Broker) and/or comparing user traces.
It also wouldn't have been clear enough about what (unnecessarily) harms performance. In your case it also harms the code-robustness:
The use of INDEX ([]) tends to lead to "array out of bounds exceptions", which you can avoid by JUST NOT USING INDEX! |
I thought I was optimistic !... people do not read the doc, and you expect them to read your rules ?!!!! |
|
Back to top |
|
|
mqsiuser |
Posted: Sun Aug 11, 2013 9:22 am Post subject: |
|
|
Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
I will be there to remind people _________________ Just use REFERENCEs |
|
Back to top |
|
|
smdavies99 |
Posted: Sun Aug 11, 2013 10:53 am Post subject: |
|
|
Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mqsiuser wrote: |
I will be there to remind people |
You vill obey ze rules, or you vill be made to work only in Java {said in an awful german accent}
{I am joking ok...} _________________ 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 |
|
|
mqsiuser |
Posted: Sun Aug 11, 2013 11:50 am Post subject: |
|
|
Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Java is great... for... äh... for... ja ... for... ja was denn nun...
Java-Application-Servers ... ... maybe?
The evolution of the IT industry
I need to talk with James Gosling, ah, no... Larry.
In Memory of the love-couple Java & XML _________________ Just use REFERENCEs |
|
Back to top |
|
|
Vinayak.Satapute |
Posted: Wed Aug 14, 2013 3:49 am Post subject: |
|
|
Acolyte
Joined: 20 Dec 2006 Posts: 70
|
dogorsy and guys,
Thanks for the inputs. It was 'dDate' variable causing the array index out of bound. Hence has been resolved.
Thanks Again. Cheers.. |
|
Back to top |
|
|
|