|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Referencing Constants in a separate Broker Schema |
« View previous topic :: View next topic » |
Author |
Message
|
wolstek |
Posted: Fri Feb 11, 2005 9:37 am Post subject: Referencing Constants in a separate Broker Schema |
|
|
Acolyte
Joined: 25 Jun 2001 Posts: 52 Location: Bristol, UK
|
WBIMB V5 CSD4
I have been trying to work out how to use Broker schemas to re-use code/procedures. As per previous posts, the documentation and examples to demonstrate how this should be coded in somewhat scarce. I have seen the various posts regarding passing InputRoot as a reference variable to a schema scope procedure ( http://www.mqseries.net/phpBB/viewtopic.php?t=10595 ) (e.g to have a common copyentiremessae and copymessage headers, rather than in every node esql and have coded this but have not yet shown it to work as I cannot deploy. I get errors such as "correlation name 'varname' is not valid". (I also have the same problem shown in post http://www.mqseries.net/phpBB/viewtopic.php?t=18738 where it gets errors showing that a variable has been defined more than once even though they haven't, so far getting around with renames)
The reason for the error is, I believe, because I have been trying to declare constants in a separate broker schema so that they only need to be defined in one place but used by many flows. I probably have the syntax across the various eSQL wrong but cannot find any info on the correct way to do this. Any help would be appreciated
Within the same Flow Project
I have created a Broker Schema called "Common_Vars", In this I have an esql file containing
Code: |
BROKER SCHEMA Common_Vars
DECLARE CONSTANT varname CHARACTER 'varcontent';
...
...
CREATE PROCEDURE CopyEntireMessage(IN InputRoot REFERENCE, INOUT OutputRoot REFERENCE) BEGIN
SET OutputRoot = InputRoot;
END;
CREATE PROCEDURE CopyMessageHeaders(IN InputRoot REFERENCE, IN OutputRoot REFERENCE) BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(InputRoot.*[]);
WHILE I < J DO
-- Create the parser
CREATE LASTCHILD OF OutputRoot DOMAIN FIELDNAME(InputRoot.*[I]);
-- Copy values to the newly created parser
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyLocalEnvironment(IN InputLocalEnvironment REFERENCE, INOUT OutputLocalEnvironment REFERENCE) BEGIN
SET OutputLocalEnvironment = InputLocalEnvironment;
END;
|
I then have another broker schema called Main_Flows
In this I have a flow with esql file containing
Code: |
BROKER SCHEMA Main_Flows PATH Common_Vars;
CREATE COMPUTE MODULE TestFlow_SetParameters
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders(InputRoot, OutputRoot);
CALL CopyLocalEnvironment(InputLocalEnvironment, OutputLocalEnvironment);
CALL SetParameters();
RETURN TRUE;
END;
CREATE PROCEDURE SetParameters() BEGIN
SET Environment.Variables.Service.Name = varname;
.....
.....
END;
END MODULE;
|
The problem is essentially that the varname in SetParameters is not valid even though it is defined in Common_Vars which is also in the PATH for Main_Flows.
Another thing I find strange. If on the BROKER SCHEMA when there is no PATH defined you do not need a semi-colon at the end of the line (if you do the editor shows an error). If you do have PATH defined, you do need a semi-colon?
Many Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Feb 12, 2005 8:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Have you tried using Common_Vars:varname? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wolstek |
Posted: Mon Feb 14, 2005 1:52 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2001 Posts: 52 Location: Bristol, UK
|
Common_Vars:varname is not valid syntax according to the eSQL editor.
I have been digging further and rereading then manual and found the following statement
Quote: |
Constants
Constants are locally reusable and can be used where they are defined in any ESQL or mapping file within the same broker schema.
Constants are not globally reusable; you cannot use a constant that is declared in another schema.
|
So apologies, I was trying to do something that is not supported. |
|
Back to top |
|
 |
chibban |
Posted: Sun Nov 27, 2005 2:53 pm Post subject: |
|
|
Novice
Joined: 01 Jun 2005 Posts: 14
|
Is there any other way to define global variables ones in a shared schema and use them from another schema ? _________________ Thanks,
Sivan |
|
Back to top |
|
 |
mgk |
Posted: Mon Nov 28, 2005 1:36 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
The way to do this, if you really want to do it, is to provide get / set functions in the schema that declares the variable. The function can then get / set the variable when you call it.
Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
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
|
|
|
|