|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Array subscript error |
« View previous topic :: View next topic » |
Author |
Message
|
siri2083 |
Posted: Thu Apr 23, 2009 11:17 pm Post subject: Array subscript error |
|
|
Apprentice
Joined: 16 Apr 2009 Posts: 39
|
Hi,
I am facing an error saying 'Array subscript error' when i am trying to assign to an environment variable.
my code looks like below:
DECLARE IN_IDs INTEGER;
SET IN_IDs = CARDINALITY(Environment.Variables.BeforeImage.allClients.Client[]);
WHILE IN_IDs <> 0 DO
SET Environment.Variables.BeforeImage.MembershipsDetails.Membership[IN_IDs].Details[]= SELECT MEMSHIP.CLIENTID, MEMSHIP.MEMBERSHIPNUMBER, MEMSHIP.MEMBERSHIPTYPE,MEMSHIP.MEMBERSHIPSTARTDATE,MEMSHIP.MEMBERSHIPSTATUS FROM Database.ADMINISTRATOR.IAL_RT_MEMBERSHIP AS MEMSHIP WHERE MEMSHIP.CLIENTID = Environment.Variables.BeforeImage.allClients.Client[IN_IDs].CLIENTID;
SET IN_IDs = IN_IDs - 1;
END WHILE;
Please note here CLIENTID is not a primary key. so for each ClientId, i need to retrive all the info from the DB table and assign to environment tree.
 |
|
Back to top |
|
 |
Vitor |
Posted: Thu Apr 23, 2009 11:31 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
It's not clear from this snippit if the Environment.Variables.BeforeImage.MembershipDetails.Membership tree exists when the code is run. This is a different tree from the Environment.Varables.BeforeImage.allClients.Client, despite being stored in the same area.
If it doesn't exist, you're attempting to create the IN_IDth element before the IN_IDth-1 is in place. That's not allowed and will give you the error you quote; go up not down.
If it does exist, use trace (or other diagnostic) to check both trees have the same cardinality. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
siri2083 |
Posted: Thu Apr 23, 2009 11:51 pm Post subject: |
|
|
Apprentice
Joined: 16 Apr 2009 Posts: 39
|
Hi,
Thanks for the reply. The problem is solved. the description of the problem is:
i am trying to assign Environment.Variables.BeforeImage.MembershipsDetails.Membership[IN_IDs].Details[].
for example for the first time IN_IDs = 3. where Environment.Variables.BeforeImage.MembershipsDetails.Membership[3].Details[]. array is not allowed to create untill it has Environment.Variables.BeforeImage.MembershipsDetails.Membership[2].Details[].
below code reolves the probelm:
DECLARE IN_IDs,Count INTEGER;
SET IN_IDs = CARDINALITY(Environment.Variables.BeforeImage.allClients.Client[]);
SET Count = 1;
WHILE Count <= IN_IDs DO
SET Environment.Variables.BeforeImage.MembershipsDetails.Membership[Count].Details[]= SELECT MEMSHIP.CLIENTID, MEMSHIP.MEMBERSHIPNUMBER, MEMSHIP.MEMBERSHIPTYPE,MEMSHIP.MEMBERSHIPSTARTDATE,MEMSHIP.MEMBERSHIPSTATUS FROM Database.ADMINISTRATOR.IAL_RT_MEMBERSHIP AS MEMSHIP WHERE MEMSHIP.CLIENTID = Environment.Variables.BeforeImage.allClients.Client[Count].CLIENTID;
SET Count= Count + 1;
END WHILE; |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|