Author |
Message
|
polydegmon |
Posted: Fri Oct 07, 2011 5:10 am Post subject: Accessing Shared Variables |
|
|
Novice
Joined: 07 Oct 2011 Posts: 11
|
I'm using a shared variable to store a set of rules that need to be accessed in other flows in the EXE group. However I'm getting an error with it.
The shared row is defined in subflow A, outside the module scope.
Code: |
DECLARE CachedRulesTable SHARED ROW; |
It's being set in subflow A inside a ESQL compute node module, it's not being set in the Main function however it's been set in a procedure that's called by the main function.
Code: |
ROUTING : BEGIN ATOMIC
SET CachedRulesTable.QueryParameters.SearchParams.notsearchable = 'TEST';
END;
|
I need to access it in subflow B, the code I'm using is below
Code: |
DECLARE Result ROW;
SET Result.Info[] = (SELECT R.notsearchable
FROM CachedRulesTable.QueryParameters.SearchParams[] AS R
WHERE R.name = SearchParmID);
|
I only get the error when I try to deploy it, the error I get is
Quote: |
The correlation name 'CachedRulesTable' is not valid. |
Any help on this would be greatly appreciated.
Thanks |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 07, 2011 5:11 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Shared variables are scoped to either the module or the schema they are defined in.
Shared variables are only exposed to other instances of the SAME message flow, you can NOT use them to share data BETWEEN message flows. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri Oct 07, 2011 6:03 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
If you attend the IBM provided training class WM663, the instructor will show you how to share data between flows and between nodes of a flow. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
polydegmon |
Posted: Fri Oct 07, 2011 6:32 am Post subject: |
|
|
Novice
Joined: 07 Oct 2011 Posts: 11
|
Hi lancelotlinc i attended an IBM course a few months ago in london where we did learn about the use of shared variables and the atomic keyword to protect them, however there was no code example of how to do it. Just a brief talk on how it could be done.
If you could let me know or point me in the right direction I'd appreciate it.
Thanks |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 07, 2011 6:41 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
polydegmon wrote: |
Hi lancelotlinc i attended an IBM course a few months ago in london where we did learn about the use of shared variables and the atomic keyword to protect them, however there was no code example of how to do it. Just a brief talk on how it could be done.
If you could let me know or point me in the right direction I'd appreciate it.
Thanks |
The code you have is fine for sharing data across instances of a single message flow.
SHARED variables DO NOT let you share data between message flows.
There are many other ways, with varying different complexities and performance costs, that DO let you share data between message flows.
Do some searching, do some thinking, you'll find a few. Do some testing to make sure you meet your own requirements. |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Oct 07, 2011 6:41 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
polydegmon wrote: |
If you could let me know or point me in the right direction I'd appreciate it.
Thanks |
I figured it out about 5 years ago. It isn't that hard. Just have all the instances call a procedure which has the ATOMIC block inside it.
Go on, experiment. You might be surprised at what you can find out for yourself.... _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 07, 2011 6:43 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
smdavies99 wrote: |
polydegmon wrote: |
If you could let me know or point me in the right direction I'd appreciate it.
Thanks |
I figured it out about 5 years ago. |
SHARED variables didn't exist five years ago. |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Oct 07, 2011 6:53 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mqjeff wrote: |
SHARED variables didn't exist five years ago. |
I used them with V6.0 which If I remember correctly came out in 2006. But as the saying goes, time files and corrupts memory. So it could have been 2007. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 07, 2011 6:56 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
smdavies99 wrote: |
mqjeff wrote: |
SHARED variables didn't exist five years ago. |
I used them with V6.0 which If I remember correctly came out in 2006. But as the saying goes, time files and corrupts memory. So it could have been 2007. |
Oh goodness.
Where's that banana?
 |
|
Back to top |
|
 |
Vitor |
Posted: Fri Oct 07, 2011 7:16 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
Oh goodness.
Where's that banana?
 |
Sooner or later advancing years (and increasing coffee consumption) catch up with us all.
I myself used to have a perfect memory, but now I can't remember what happened to it.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|