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 » Create an ARRAY variable in ESQL

Post new topic  Reply to topic Goto page 1, 2  Next
 Create an ARRAY variable in ESQL « View previous topic :: View next topic » 
Author Message
williad
PostPosted: Fri Feb 22, 2013 2:46 am    Post subject: Create an ARRAY variable in ESQL Reply with quote

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
View user's profile Send private message
smdavies99
PostPosted: Fri Feb 22, 2013 3:10 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Feb 22, 2013 4:25 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
williad
PostPosted: Fri Feb 22, 2013 4:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Esa
PostPosted: Fri Feb 22, 2013 5:03 am    Post subject: Reply with quote

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
View user's profile Send private message
adubya
PostPosted: Fri Feb 22, 2013 5:06 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
williad
PostPosted: Fri Feb 22, 2013 6:17 am    Post subject: Reply with quote

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
View user's profile Send private message
smdavies99
PostPosted: Fri Feb 22, 2013 6:28 am    Post subject: Reply with quote

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
View user's profile Send private message
williad
PostPosted: Fri Feb 22, 2013 6:30 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 22, 2013 6:40 am    Post subject: Reply with quote

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
View user's profile Send private message
williad
PostPosted: Fri Feb 22, 2013 8:14 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 22, 2013 8:51 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Fri Feb 22, 2013 8:57 am    Post subject: Reply with quote

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
View user's profile Send private message
williad
PostPosted: Sun Feb 24, 2013 4:12 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Sun Feb 24, 2013 8:08 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Create an ARRAY variable in 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.