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 » Dynamically updating a reference data type

Post new topic  Reply to topic
 Dynamically updating a reference data type « View previous topic :: View next topic » 
Author Message
darioo
PostPosted: Thu Oct 09, 2014 10:02 am    Post subject: Dynamically updating a reference data type Reply with quote

Novice

Joined: 19 Mar 2009
Posts: 15

Greetings everyone, I'm using WMB7.

I'm wondering if it's possible to change where a declared reference variable points to?

Something like this (non working code follows):

Code:

DECLARE myref REFERENCE TO Environment.Variable.Something;
... some code ...
SET myref REFERENCE = Environment.Variable.SomethingElse; -- won't work
SET myref = 50;  -- effectively "SET Environment.Variable.SomethingElse = 50;"


since using

Code:

SET myref = Environment.Variable.SomethingElse


is effectively

Code:

SET Environment.Variable.Something = Environment.Variable.SomethingElse;


and it's not what I wanted. Image I want something like pointers in C.


Rationale (read if you have some time): data gets pulled from a database using ESQL ODBC. Two rows are returned, let's say one of them represents "BUY", other one "SELL", these are values from one of database columns.

ESQL doesn't have an ORDER BY clause when SELECTing from a database, so I can never be quite sure which row is "BUY" and which one is "SELL".

Code:

myData.rows[1] -- might be "BUY" or "SELL"
myData.rows[2] -- the opposite value



So, I thought it would be nice to do something like creating two empty references "buyRef" and "sellRef", then assigning to them appropriate rows after checking their values in an IF...ELSE. Alas, not possible.

Another thing I hoped that would work is doing something like:

Code:

IF myData.rows[1].orderType = 'BUY' THEN
   DECLARE buyRef REFERENCE TO myData.rows[1];
   DECLARE sellRef REFERENCE TO myData.rows[2];
ELSE
   DECLARE buyRef REFERENCE TO myData.rows[2];
   DECLARE sellRef REFERENCE TO myData.rows[1];
END IF;


but this won't work because of scoping issues when I want to access references later in code.

I have found few workarounds how to solve this problem:

    1. PASSTHRU statement
    2. two ESQL queries with a WHERE statement (doubling amount of DB calls)
    3. using Java
    4. some ESQL trickery


but was left wondering what would be the most elegant solution to this problem using pure ESQL.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Oct 09, 2014 10:07 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

If you want to change where a reference points, you can MOVE it.

If you want to test the value of an element you can use FIELDVALUE. Likewise if you want to test the Name of an element, you can test FIELDNAME.

If you want to access a child of an element (a single level only) by name, you can use {}, like MOVE myRef to Environment.Variables.{'buy'}
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Oct 09, 2014 12:46 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

ESQL does not allow uninitialised pointers. Some would say that's a feature, not a shortcoming. But it does have a SELECT statement, which does exactly what you need.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Oct 09, 2014 1:02 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Right, so you can't create two references that point to nowhere.

You can create two references that point to InputRoot. And then move them.
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 » Dynamically updating a reference data type
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.