Author |
Message
|
cwazpitt3 |
Posted: Fri Jan 20, 2012 9:23 am Post subject: ESQL Global Constants File |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
What I am trying to achieve seems like it should work, but I cannot seem to get it to work.
I would like to have an ESQL file that lives in a common project (or even within the same project) that will just house CONSTANTs and then use those across the application. It seems I can achieve this if everything is in the same SCHEMA, however, that is really not what I want in this case. Here is what I tried:
FILE: Constants.esql
----------------------------------------------------------------
Code: |
SCHEMA com.company.common;
DECLARE const1 CONSTANT CHARACTER 'somevalue'; |
FILE: FlowTest.esql
----------------------------------------------------------------
Code: |
SCHEMA com.company.common.flows;
PATH com.company.common;
CREATE COMPUTE MODULE FlowTest_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE testVar CHARACTER const1;
RETURN TRUE;
END;
END MODULE; |
Now with this setup, I get warnings in Toolkit and when I deploy, I get a "correlation name 'const1' is not valid" error. Now I have tried putting the constant esql in broker schema as some documentation eludes to it may work that way, but no luck there either. If I would move constants into the same SCHEMA as the FlowTest, it would work.
Is this just not possible in ESQL? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jan 20, 2012 9:53 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
cwazpitt3 |
Posted: Fri Jan 20, 2012 11:54 am Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
I have seen this, but as I re-read it, I notice it mentions functions and procedures but not constants
Quote: |
The PATH clause is used to resolve unqualified function and procedure names in the tools according to the following algorithm. |
Is this what you meant for me to get out of that? |
|
Back to top |
|
 |
adubya |
Posted: Fri Jan 20, 2012 12:04 pm Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri Jan 20, 2012 12:25 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
cwazpitt3 |
Posted: Fri Jan 20, 2012 1:01 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
lancelotlinc wrote: |
Another great use-case for solidDB !! |
Might be overkill for this application, but certainty seems like a viable option for future projects. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jan 20, 2012 1:15 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
I don't think IMHO the constant word as meant in that part of the documentation referred to constant variables... more to the syntactical make up of the broker code isolation levels...
Those isolation levels will then dictate the scope.
Remember the scope can be modified by things like the PATH keyword...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mgk |
Posted: Fri Jan 20, 2012 1:33 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
Constants (and namespace declarations) can't be shared across schemas |
This is correct. However, there is a simple way to achieve this which is to add a "getter" Function which returns the constant as Functions can be shared across schemas.
Kind 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 |
|
 |
fjb_saper |
Posted: Fri Jan 20, 2012 1:37 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Thanks for qualifying this mgk.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Jan 23, 2012 11:44 am Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
mgk wrote: |
This is correct. However, there is a simple way to achieve this which is to add a "getter" Function which returns the constant as Functions can be shared across schemas. |
This is what I had done in place of constants, just wanted to get clarification that I wasn't missing something. Thanks for your help!
 |
|
Back to top |
|
 |
|