|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Call a function with a reference to ROW (ESQL) |
« View previous topic :: View next topic » |
Author |
Message
|
OfficeWorker |
Posted: Sun Aug 05, 2012 4:54 pm Post subject: Call a function with a reference to ROW (ESQL) |
|
|
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 |
|
 |
mqjeff |
Posted: Mon Aug 06, 2012 1:28 am Post subject: |
|
|
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 |
|
 |
Muggy |
Posted: Sat Aug 11, 2012 7:26 am Post subject: |
|
|
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 |
|
 |
OfficeWorker |
Posted: Tue Aug 28, 2012 6:07 pm Post subject: |
|
|
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 |
|
 |
|
|
 |
|
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
|
|
|
|