Author |
Message
|
williad |
Posted: Fri Feb 22, 2013 2:46 am Post subject: Create an ARRAY variable in ESQL |
|
|
Apprentice
Joined: 08 Sep 2005 Posts: 40 Location: London
|
Hi
Is it possible to declare a variable of an ARRAY type in ESQL.
From what i can see you can only use ARRAY variables as part of the Environment Tree.
Where I am coming from is that i have a sub procedure within a compute node which uses the Environment.Variables.zzz[] to create an ARRAY. I now want to make that sub procedure into a common procedure so that it can be used by other procedures in other message flows. When i try do this, and deploy the bar file, the error returned says Environment correlation name is not valid and out of scope. I am taking this to mean that the Environment Tree can only be used within defined node ESQL (hope that makes sense)
Thanks for your time |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Feb 22, 2013 3:10 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Pass 'Environment' to the procedure as a reference parameter.
something like this
Code: |
declare evnRef REFERENCE to Environment;
call myproc(...,...,..., envRef);
|
Code: |
create procedure myproc(..., ..., ..., INOUT envRef REFERENCE) begin
|
_________________ 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 |
|
 |
fjb_saper |
Posted: Fri Feb 22, 2013 4:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
smdavies99 wrote: |
Pass 'Environment' to the procedure as a reference parameter.
something like this
Code: |
declare evnRef REFERENCE to Environment;
call myproc(...,...,..., envRef);
|
Code: |
create procedure myproc(..., ..., ..., INOUT envRef REFERENCE) begin
|
|
Wouldn't use INOUT on a REFERENCE.
Only use INOUT on a reference if the reference you are passing out is not pointing to the same place as the reference you passed into the proc.
Otherwise passing a ref as IN type is enough. You can still change the children and the caller will see the changes.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
williad |
Posted: Fri Feb 22, 2013 4:52 am Post subject: |
|
|
Apprentice
Joined: 08 Sep 2005 Posts: 40 Location: London
|
Hi guys
Thank you very much for this.
The procedure is working internally now as expected with the amendedment you suggested. But i am facing another problem now whereby for example I have passed down the Outputroot as a reference (INOUT) and amended the OutputRoot.BLOB.BLOB withini the procedure.
How do i retain the value being passed back to the calling procedure, becuase i tried SET OutputRoot = refOutputRoot, and SET OutputRoot.*[] = refOutputRoot.*[] and both ways are failing. error stating that the message is cut short, unable to perform copy element .... Properties is a child of element ....
Thanks again |
|
Back to top |
|
 |
Esa |
Posted: Fri Feb 22, 2013 5:03 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
williad wrote: |
The procedure is working internally now as expected with the amendedment you suggested. But i am facing another problem now whereby for example I have passed down the Outputroot as a reference (INOUT) and amended the OutputRoot.BLOB.BLOB withini the procedure.
How do i retain the value being passed back to the calling procedure, becuase i tried SET OutputRoot = refOutputRoot, and SET OutputRoot.*[] = refOutputRoot.*[] and both ways are failing. error stating that the message is cut short, unable to perform copy element .... Properties is a child of element ....
|
As pointed out by fjb_saper, there should be no valid reason for passing a reference variable as an INOUT parameter. Pass it as an IN parameter and you don't need to retain. |
|
Back to top |
|
 |
adubya |
Posted: Fri Feb 22, 2013 5:06 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
Your refOutputRoot is a reference/pointer to the real OutputRoot, when you manipulate refOutputRoot and it's descendants then you're effectively manipulating OutputRoot also. So trying to SET OutputRoot.*[] = refOutputRoot.*[] is setting OutputRoot to itself.
So use refOutputRoot in your procedure, perform the necessary manipulation on that and then return, done! When you return then OutputRoot will reflect the changes you made in your procedure.
Edit: And as above, define the refOutputRoot as an IN parameter. |
|
Back to top |
|
 |
williad |
Posted: Fri Feb 22, 2013 6:17 am Post subject: |
|
|
Apprentice
Joined: 08 Sep 2005 Posts: 40 Location: London
|
Apologies
This has now worked. Thank you all for this, it much appreciated!
May i ask another question relating to this. Is the true same for the OutputLocalEnvironment variable being passed in, as i amending its EMAIL properties. but when the EmailOutput node encounters the message it fails saying
Message passed to the EmailOutput node has a body folder of BLOB and owing parset of MQRoot. This is not supported by this node
but when the code is run with the sub procedure as part of the compute node. it works. I have compared the trace of the two methods and the message trees look identical
I was hoping that the same that was applied in the earlier post would work, but it doesnt seem to. Is the OutputLocalEnvironment the exception?
Thanks again |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Feb 22, 2013 6:28 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
If you have some ESQL in a function/procedure that is outside the compute module that calls it then you need to pass everything that the procedure/function requires as a parameter.
I have some functions that use have 4 params passed as references.
(InputRoot, OutputRoot, Environment and OutputLocalEnvironment)
Look at the number of warnings the toolkit gives you. This will help you find the problematic ones. _________________ 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 |
|
 |
williad |
Posted: Fri Feb 22, 2013 6:30 am Post subject: |
|
|
Apprentice
Joined: 08 Sep 2005 Posts: 40 Location: London
|
Skip that last post from me ..... the traces are different
(0x01000000:Name):EmailOutputHeader = ( ['EMAILHDR' : 0x10a85aaa8]
(0x03000000:NameValue):To = 'derrick.williams@schroders.com' (CHARACTER)
(0x03000000:NameValue):Cc = '' (CHARACTER)
(0x03000000:NameValue):Bcc = '' (CHARACTER)
(0x03000000:NameValue):From = '' (CHARACTER)
(0x03000000:NameValue):Reply-To = '' (CHARACTER)
(0x03000000:NameValue):Subject = 'DV1: Counterparties to SCD Interest' (CHARACTER)
)
(0x01000000:Name):BLOB = ( ['none' : 0x10a85aeb0]
(0x03000000:NameValue):BLOB = X'...........
the sections above (extract from trace) that are in bold are not present in the not working trace.. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Feb 22, 2013 6:40 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
BLOB is a parser.
Apparently EmailOutputHeader is a parser.
Trees created under Environment and LocalEnvironment are not associated with parsers by default. |
|
Back to top |
|
 |
williad |
Posted: Fri Feb 22, 2013 8:14 am Post subject: |
|
|
Apprentice
Joined: 08 Sep 2005 Posts: 40 Location: London
|
Hi
Thanks for that. Not sure i understand when you say not created by default, how do i do that? I would of thought that passing in the OutputLocalEnvironment as a reference and IN, from what i have learned so far, would not have changed any of the headers |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Feb 22, 2013 8:51 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Passing it as a parameter does not, indeed, change anything about the structures that have already been created.
But
Code: |
Set OutputRoot.BLOB.BLOB = X'abcd'; |
will very likely work differently than
Code: |
set myRef.BLOB.BLOB = X'abcd'; |
|
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 22, 2013 8:57 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
williad wrote: |
Not sure i understand when you say not created by default, how do i do that? |
The Environment trees don't have parsers automatically associated like the Root tree does. You have to associate them when you create the environment entry.
williad wrote: |
I would of thought that passing in the OutputLocalEnvironment as a reference and IN, from what i have learned so far, would not have changed any of the headers |
It won't change the headers. It also won't associate a parser with the header; you have to do that. Look up the DOMAIN clause of the CREATE statement. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
williad |
Posted: Sun Feb 24, 2013 4:12 am Post subject: |
|
|
Apprentice
Joined: 08 Sep 2005 Posts: 40 Location: London
|
Hi
Thank you
I think i may have misled you guys a little, apologies, i have just noticed it by lookng at the two traces again, the bolden bits are not part of the OutputLocalEnvironment tree, but are part of the OutputRoot Tree headers.
does this make a difference? |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Feb 24, 2013 8:08 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
williad wrote: |
Hi
Thank you
I think i may have misled you guys a little, apologies, i have just noticed it by lookng at the two traces again, the bolden bits are not part of the OutputLocalEnvironment tree, but are part of the OutputRoot Tree headers.
does this make a difference? |
Yes it does. See the previous post about parser associations in non outputRoot trees.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|