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 » Call a function with a reference to ROW (ESQL)

Post new topic  Reply to topic
 Call a function with a reference to ROW (ESQL) « View previous topic :: View next topic » 
Author Message
OfficeWorker
PostPosted: Sun Aug 05, 2012 4:54 pm    Post subject: Call a function with a reference to ROW (ESQL) Reply with quote

Novice

Joined: 05 Aug 2012
Posts: 11

I am a newbie to ESQL.

I have a function that I want to intialise a whole bunch of values on a row.

After discovering a row cannot be passed in to a function, I found out I could pass it in as a reference, like so:
Code:

   CREATE FUNCTION InitialiseValues(INOUT item REFERENCE) BEGIN
      SET item.RowNum = '';
      SET item.PersonId = '';
...


However, I also found I could not pass the row directly, and had to do this.
Code:

DECLARE item ROW;
DECLARE ref_item REFERENCE TO item;
CALL InitialiseValues(ref_item);


Is there a clean way of doing this, without having to declare the reference variable?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Aug 06, 2012 1:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Well, if you declare the row at Schema scope, rather than at Module scope, you don't have to pass it.

Back to top
View user's profile Send private message
Muggy
PostPosted: Sat Aug 11, 2012 7:26 am    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2012
Posts: 4

Probably a little late in replying, but I only read the forum on occasion. Though the suggestion from mqjeff is valid, it may not be the most suitable for your needs.

To get the code to function as requested, without declaring the additional reference and without a global variable *shudders*, you would need to change the INOUT to just IN. A ROW Data type behaves as a constant in regards to the INOUT parameter, which makes sense.

For example, the INOUT parameter would allow you to MOVE the reference to any further elements defined in ROW (or any other tree or row in scope for that matter) and 'return' the updated reference to that element. But you wouldn't want to try that with a ROW, as the original ROW would become 'lost'.
Back to top
View user's profile Send private message
OfficeWorker
PostPosted: Tue Aug 28, 2012 6:07 pm    Post subject: Reply with quote

Novice

Joined: 05 Aug 2012
Posts: 11

Muggy,

Finally got a chance to try your suggestion.

Ah now I understand what INOUT means.. It worked, Thanks!
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 » Call a function with a reference to ROW (ESQL)
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.