Author |
Message
|
philips79 |
Posted: Mon Jun 02, 2014 8:55 am Post subject: Why do we need to declare a constant as Shared Constant? |
|
|
Newbie
Joined: 02 Jun 2014 Posts: 2
|
In ESQL we have SHARED CONSTANTS, Why do we need them when they are constant and they don't change even if multiple threads access the same value.
DECLARE MYCONST SHARED CONSTANT CHAR 'My Constant'; |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 02, 2014 9:39 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You don't have to. However it makes sense when you know that the value will not change across multiple instances of the flow...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
philips79 |
Posted: Tue Jun 03, 2014 1:44 am Post subject: |
|
|
Newbie
Joined: 02 Jun 2014 Posts: 2
|
Can you tell me how can any other flow instance change a CONSTANT value?
Constant are meant to fixed values. so they are declared as constants.
How can A constant value change??? Sorry I am confused....... |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jun 04, 2014 5:51 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
philips79 wrote: |
Can you tell me how can any other flow instance change a CONSTANT value?
Constant are meant to fixed values. so they are declared as constants.
How can A constant value change??? Sorry I am confused....... |
It's not about changing the value. It's about accessing it.
Making it shared allows you to define it once and access it many times depending on the scope in your declaration...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Esa |
Posted: Wed Jun 04, 2014 11:55 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
fjb_saper wrote: |
It's about accessing it.
Making it shared allows you to define it once and access it many times depending on the scope in your declaration...  |
fjb_saper, please elaborate with an example.
You cannot access a constant from another broker schema even if it was SHARED.
You can access a schema level constant declared on the same schema regardless if it is SHARED or not. And you only can declare it once regardless if it's SHARED or not.
You cannot access a constant declared in some other module on the same schema regardless if it's SHARED or not.
You cannot declare a constant within a function or procedure.
So what is the difference between a SHARED CONSTANT and an ordinary CONSTANT? There must be something that I have overlooked? |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jun 05, 2014 6:25 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
A SHARED constant will only be defined once.
A non-shared CONSTANT will be redefined in each ESQL node that uses the schema. |
|
Back to top |
|
 |
Esa |
Posted: Thu Jun 05, 2014 6:55 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
mqjeff wrote: |
A SHARED constant will only be defined once.
A non-shared CONSTANT will be redefined in each ESQL node that uses the schema. |
Thanks, mqjeff. That makes sense. So declaring a constant as shared may make the compiled flow footprint a little smaller in runtime if the constant is accessed by several nodes. |
|
Back to top |
|
 |
|