|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Dynamic REFERENCE statement |
« View previous topic :: View next topic » |
Author |
Message
|
fitzcaraldo |
Posted: Fri Aug 29, 2003 3:30 am Post subject: Dynamic REFERENCE statement |
|
|
Voyager
Joined: 05 May 2003 Posts: 98
|
Is it possible to dynamically create a REFERENCE statement
eg instead of
set Field1 = 'Message';
set Field2 = 'Item';
set Field3 = 'Name';
declare ref REFERENCE to InputRoot.XML.{Field1}.{Field2}.{Field3}
which works,
i want to do
set SingleXMLField = 'Message.Item.Name'
declare ref REFERENCE to InputRoot.XML.{SingleXMLField}
which doesn't...
I may be dealing with a dynamic number of fields and I don't what to code a declare for ever possibility.
Any ideas? |
|
Back to top |
|
 |
lillo |
Posted: Fri Aug 29, 2003 4:15 am Post subject: |
|
|
Master
Joined: 11 Sep 2001 Posts: 224
|
It is not posible as you suggest. Had your tried using with the EVAL function? Remember the EVAL function has an impact in the performance. _________________ Lillo
IBM Certified Specialist - WebSphere MQ |
|
Back to top |
|
 |
Craig B |
Posted: Fri Aug 29, 2003 6:56 am Post subject: |
|
|
Partisan
Joined: 18 Jun 2003 Posts: 316 Location: UK
|
Hi,
DECLARE statements are not allowed within an EVAL Statement so you could not use the EVAL statement to dynamically declare your reference variable. Therefore if you did go down the EVAL route, then you would have to DECLARE your reference variable to point to some constants or variable to being with, then code your EVAL statement to MOVE the predefined reference to your field reference.
However it would seem that what you are trying to do goes against what REFERENCE variables were introduced for. The concept behind a reference variable is that you can anonymously navigate a message tree, without specifically knowing names of fields or the structure of the message (but obviously not both). By wanting to dynamically DECLARE a reference variable to one of many predefined possible names in your input message would seem to go against this. Have you considered DECLAREing your reference variable to the root element of the message tree. Then use the MOVE statement to go to a child you require, where you can choose to specify a variable name or not. Just a thought to consider. _________________ Regards
Craig |
|
Back to top |
|
 |
kirani |
Posted: Sat Aug 30, 2003 8:07 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
fitzcaraldo,
I had similar problems long time back, I think I then switched to individual fields. You can try this,
Code: |
set SingleXMLField = '"Message"."Item"."Name"'
declare ref REFERENCE to InputRoot.XML.{SingleXMLField}
|
_________________ 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 |
|
 |
fitzcaraldo |
Posted: Mon Sep 01, 2003 10:02 pm Post subject: |
|
|
Voyager
Joined: 05 May 2003 Posts: 98
|
Thanks to both of you for your help.
I tried what you suggest Kirani and while syntactically it looks OK, attempting to use a reference defined in such a way always returned null.
I ended up using the technique you suggested Craig and it works fine so thank you. |
|
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
|
|
|
|