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 » Using an array in a REFERENCE statement

Post new topic  Reply to topic
 Using an array in a REFERENCE statement « View previous topic :: View next topic » 
Author Message
smeunier
PostPosted: Mon Nov 17, 2003 2:40 pm    Post subject: Using an array in a REFERENCE statement Reply with quote

Partisan

Joined: 19 Aug 2002
Posts: 305
Location: Green Mountains of Vermont

I have been trying to use an dynamic array index in a REFERENCE statement within a loop, where the array index needs to reference the current value of the loop counter. I get no errors, but no data either. Does anyone know how to do this? Is there another approach?

Below is an example:

Code:

DECLARE I INTEGER;
DECLARE C INTEGER;
DECLARE RefToOutputRoot REFERENCE TO OutputRoot.XML.(XML.Element)Z_SHIPMENT.Z1SHIPMENT_DATA[I];

SET C = 5;
SET I = 1;


WHILE I <= C DO

  SET RefToOutputRoot.(XML.Attribute)SEGMENT= '1';
END WHILE;

The expect result would be:

<Z_SHIPMENT>
  <Z1SHIPMENT_DATA SEGMENT='1'/>
  <Z1SHIPMENT_DATA SEGMENT='1'/>
  <Z1SHIPMENT_DATA SEGMENT='1'/>
  <Z1SHIPMENT_DATA SEGMENT='1'/>
  <Z1SHIPMENT_DATA SEGMENT='1'/>
</Z_SHIPMENT>

 
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Nov 17, 2003 2:59 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I don't think references work that way.

I'd try something like
Code:
DECLARE I INTEGER;
DECLARE C INTEGER;
DECLARE RefToOutputRoot REFERENCE TO OutputRoot.XML.(XML.Element)Z_SHIPMENT.Z1SHIPMENT_DATA[1];
 
SET C = 5;
SET I = 1;
 
WHILE I <= C DO 
  SET RefToOutputRoot.(XML.Attribute)SEGMENT= '1';
  SET I = I + 1;
  MOVE RefToOutputRoot NEXTSIBLING NAME 'Z1SHIPMENT_DATA';
END WHILE;
But I have not tried this particular code, so it may need some tweaking to compile.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
dsim
PostPosted: Mon Nov 17, 2003 8:36 pm    Post subject: Reply with quote

Acolyte

Joined: 11 Aug 2003
Posts: 67
Location: Toronto

Another try would be (also not compiled):
Code:
DECLARE I INTEGER;
DECLARE C INTEGER;

SET C = 5;
SET I = 1;

WHILE I <= C DO
  SET OutputRoot.XML.Z_SHIPMENT.Z1SHIPMENT_DATA[I].(XML.Attribute)SEGMENT= '1'; 
END WHILE;
Back to top
View user's profile Send private message
Missam
PostPosted: Thu Nov 20, 2003 12:39 pm    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Hi,
There is no need to reference you can directly do like this

DECLARE I INTEGER;
DECLARE C INTEGER;

SET C = 5;
SET I = 1;

WHILE I <= C DO
SET OutputRoot.XML.Z_SHIPMENT."Z1SHIPMENT_DATA"[I].(XML.Attribute)SEGMENT= '1';
SET I = I + 1;
END WHILE;
you can also do it using refereces
Thanx
Sam
Back to top
View user's profile Send private message
dsim
PostPosted: Thu Nov 20, 2003 2:26 pm    Post subject: Reply with quote

Acolyte

Joined: 11 Aug 2003
Posts: 67
Location: Toronto

IamSam,
Right, I have a missing
Code:
SET I = I + 1;

in the loop.
Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 20, 2003 5:25 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

dsim wrote:
IamSam,
Right, I have a missing
Code:
SET I = I + 1;

in the loop.
Thanks


So did the original poster.

And, for everyone's information, in this particular case, where you are only looping 5 times, it does not matter. But using Reference variables are much faster than using an array index.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Using an array in a REFERENCE statement
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.