Author |
Message
|
msgbrkr |
Posted: Mon May 10, 2004 9:38 am Post subject: array subscript error |
|
|
Newbie
Joined: 21 Apr 2004 Posts: 9
|
Hi,
i have this esql like:
Set cnt = 1;
SET OutputRoot.XML.Customer[cnt].address.home = ......
IF CARDINALITY(......) > 0 THEN
-- If some values are present then create a second element for this array.
SET cnt = cnt +1;
SET OutputRoot.XML.Customer[cnt].address.home =.....
END IF;
Now this part throws me a "array subscript error"
Though if i specifically hardcode them as [1] while setting the first element and [2] for the second element it works fine.
Also i knw that this is normally caused when u set a value, and its prev element is still not created.
But if u see the esql code i am setting the first element and then setting the 2nd element
Any help will b appreciated.
Thanx. |
|
Back to top |
|
 |
Missam |
Posted: Mon May 10, 2004 10:45 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Code: |
Set cnt = 1;
SET OutputRoot.XML.Customer[cnt].address.home = ......
IF CARDINALITY(......) > 0 THEN
-- If some values are present then create a second element for this array.
SET cnt = cnt +1;
SET [b]OutputRoot.XML.Customer[cnt][/b].address.home =.....
END IF;
|
The Output XML you are trying to create will be having more than one root element(Customer).Which is not a valid XML. |
|
Back to top |
|
 |
msgbrkr |
Posted: Mon May 10, 2004 11:24 am Post subject: |
|
|
Newbie
Joined: 21 Apr 2004 Posts: 9
|
well i am really very sorry for putting in just a sample example without giving it a thought:
infact in my actual code i am setting the Env tree which is something like:
SET cnt = 1;
SET Environment.Loan.CustList.Cust[cnt].CustId = ......
IF CARDINALITY(......) > 0 THEN
SET cnt = cnt +1;
SET Environment.Loan.CustList.Cust[cnt].CustId = ......
END IF;
Thanx |
|
Back to top |
|
 |
Missam |
Posted: Mon May 10, 2004 11:43 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Hi
Now you need to concentrate on the right hand side of the statement
Code: |
SET Environment.Loan.CustList.Cust[cnt].CustId = ......
|
if the right rand operant evaluates to NULL the Cust[cnt].CustId becomes null there won't be first sibling
and then
SET cnt = cnt + 1;
cnt goes to 2
and when again evaluating the statement
Code: |
SET Environment.Loan.CustList.Cust[cnt].CustId = ......
|
it evaluates to
Environment.Loan.CustList.Cust[2].CustId
with out having the first child Cust[1].CustId .here you get array subscript error.[/code] |
|
Back to top |
|
 |
msgbrkr |
Posted: Mon May 10, 2004 1:21 pm Post subject: |
|
|
Newbie
Joined: 21 Apr 2004 Posts: 9
|
Thanks missam u were right, the 1st element was null.
But using the COALESCE function also doesnt help in overcoming the prob.
SET Environment.Loan.CustList.Cust[cnt].CustId = COALESCE(......,'');
Thanx. |
|
Back to top |
|
 |
kirani |
Posted: Sun May 16, 2004 11:32 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Quote: |
attach a trace node to out terminal of compute node and say pattern ${Environment}
it'll show you whether the field is created or not.
i think it's not the problem with COALESCE function.
|
This will help only if the second line of the code where he is creating secon index is commented out. the control will not even goto the out terminal of compute node as the exception would have been generated within the compute node itself.
Another option would be to print ${Environment} in upstream trace node connected to failure terminal or catch terminal of try-catch node or MQInput node. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
|