Author |
Message
|
Deepika |
Posted: Thu Jul 11, 2002 6:00 am Post subject: Arrays in ESQL |
|
|
Novice
Joined: 03 Jul 2002 Posts: 14
|
I want to use arrays in my ESQL to hold some data. Any one has any code example on how to do it.
many thanks |
|
Back to top |
|
 |
kirani |
Posted: Thu Jul 11, 2002 8:45 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
You could use Environment Tree to store array variables.
To set values in an Array use ESQL:
Code: |
SET Environment.Variables.NameArr[1] = 'Name1';
SET Environment.Variables.NameArr[2] = 'Name2';
SET Environment.Variables.NameArr[3] = 'Name3';
SET Environment.Variables.NameArr[4] = 'Name4';
|
To loop thru array:
Code: |
DECLARE TCNT INT;
DECLARE CNT INT;
SET TCNT = CARDINALITY(Environment.Variables.NameArr[]);
SET CNT = 1;
WHILE (I <= TCNT) DO
-- your processing goes here.
-- You could refer to arry using Environment.Variables.NameArr[I]
SET I = I + 1;
END WHILE;
...
|
Hope this helps! _________________ 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 |
|
 |
gopi_1203 |
Posted: Wed Aug 17, 2016 11:36 pm Post subject: |
|
|
Newbie
Joined: 17 Aug 2016 Posts: 2
|
we can use for loop to iterate the vaues |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Aug 18, 2016 12:34 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Can you please explain why you thought it a good thing to open a post from 2002?
That post was from the early days of this product. Time and the product have moved on since then.
Do you actually have a question?
If you do then please open a new thread and if needed, refer to the old one via a url. _________________ 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 |
|
 |
Craig B |
Posted: Tue Sep 20, 2016 2:48 am Post subject: |
|
|
Partisan
Joined: 18 Jun 2003 Posts: 316 Location: UK
|
I completely agree with the previous response. Demonstrating array index access in ESQL may be acceptable to small arrays but as soon as you scale up to many entries, the performance will be terrible. As a history lesson here each individual SET statement is executed individually and as such has to start at the first child and then go over each field checking for:
1) Is this the name of the field I need
2) Is this the Nth occurrence I am looking for.
So in the previous example if you are dealing with the 4th indexed element, the processing had to count over the previous 3 elements. Not a big deal with 4 elements, but now do this with hundreds of thousands of them.
The preferred approach here is to use REFERENCE variables and then use MOVE with NEXTSIBLING etc so that you are always navigating from the last point you last looked at.
Might be worth taking a look at the following tips in the documentation:
http://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/bj28653_.htm _________________ Regards
Craig |
|
Back to top |
|
 |
|