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 » Passing a reference argument FROM a function

Post new topic  Reply to topic
 Passing a reference argument FROM a function « View previous topic :: View next topic » 
Author Message
goffinf
PostPosted: Mon Nov 19, 2007 9:00 am    Post subject: Passing a reference argument FROM a function Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

I appreciate that variants of this question have been asked lots of times (and I've just spent quite a while reading most of them), but I can't seem to find a definitive answer for the question ... 'can I pass an updated REFERENCE argument back from a function' ?

For example (keeping things simple) I have tried this but the myRef variable does not appear to point to Environment.variables.someRef after the call (it still points to Environment) :-

-- call the function
DECLARE rc INTEGER;
DECLARE myRef REFERENCE TO Environment;

SET rc = getLocation(Environment, myRef);


CREATE FUNCTION getLocation(IN Environment REFERENCE, INOUT location REFERENCE) RETURNS INTEGER

BEGIN

CREATE FIELD Environment.variables.someRef;

DECLARE yourRef REFERENCE TO Environment.variables.someRef;
MOVE yourRef TO location;

RETURN 0;

END;

many thanks

Fraser.
Back to top
View user's profile Send private message
tleichen
PostPosted: Mon Nov 19, 2007 9:14 am    Post subject: Reply with quote

Yatiri

Joined: 11 Apr 2005
Posts: 663
Location: Center of the USA

This is an MQSeries forum; not a programming class.
_________________
IBM Certified MQSeries Specialist
IBM Certified MQSeries Developer
Back to top
View user's profile Send private message
goffinf
PostPosted: Mon Nov 19, 2007 9:19 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Perhaps I'm missing your point, this *is* an eSQL question which when I looked last was pretty much central to WBI ?
Back to top
View user's profile Send private message
mgk
PostPosted: Mon Nov 19, 2007 10:35 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi.

The simple answer to your question is yes.

Quote:
The myRef variable does not appear to point to Environment.variables.someRef after the call
.

Assuming that Environment.variables.someRef exists before you declared myRef to point it (as DECLAREing a ref to somewhere does not create elements) your problem would appear to be that you are not moving correctly, as your code:

Code:
MOVE yourRef TO location;


should be

Code:
MOVE location TO yourRef;


Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
goffinf
PostPosted: Tue Nov 20, 2007 3:03 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Thanks for that [slightly embarrasing] spot.

For the benefit of everyone else, with the fix suggested, the 'location' argument reference *is* updated and means that from the main body of code you can use it, e.g. :-

SET myref.foo = 'bar';

has the effect of creating a child under Environment.variables.someRef called 'foo' with a value of 'bar'.

We find this useful because certain loactions in the MB global environment are used for specific data and are updatable via wrapper functions. However it is sometimes more practical (rather than create an arbitrary number of wrapper functions) for a developer to update data into these locations directly. However we still want the abstraction (we may decide to change the actual location in the future), so returning a reference as above proves to be useful.

Thanks for your help

Fraser.
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 » Passing a reference argument FROM a function
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.