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 » array subscript error

Post new topic  Reply to topic
 array subscript error « View previous topic :: View next topic » 
Author Message
msgbrkr
PostPosted: Mon May 10, 2004 9:38 am    Post subject: array subscript error Reply with quote

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
View user's profile Send private message
Missam
PostPosted: Mon May 10, 2004 10:45 am    Post subject: Reply with quote

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
View user's profile Send private message
msgbrkr
PostPosted: Mon May 10, 2004 11:24 am    Post subject: Reply with quote

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
View user's profile Send private message
Missam
PostPosted: Mon May 10, 2004 11:43 am    Post subject: Reply with quote

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
View user's profile Send private message
msgbrkr
PostPosted: Mon May 10, 2004 1:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
kirani
PostPosted: Sun May 16, 2004 11:32 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » array subscript error
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.