An ESQL variable is a local temporary field used to help process a message.
You must declare a variable and state its type before you can use it. A variable's data type is fixed; if you code ESQL that assigns a value of a different type, either an implicit cast to the data type of the target is implemented or an exception is raised (if the implicit cast is not supported).
Define a variable using the DECLARE statement and give it a name. The name is case sensitive, and you must specify the exact combination of upper and lower case letters that you used when you declared it. If you do not do so, the broker might raise a runtime exception if it cannot identify the variable, or it might use the wrong variable. Check your code carefully because the ESQL validator (invoked when the ESQL file is saved) does not identify mismatches.
Assign an initial value to the variable when you declare it. You can also set its value (initial or other) using the SET statement. You can use variables in expressions and you can test its value, like other field references.
If you can predict the initial value that you want to assign to a variable, it is more efficient to provide that value on the DECLARE statement than to set the value with a separate SET statement.
The following code shows the use of some variables:
DECLARE VAR1 INTEGER 100; DECLARE Index INTEGER; SET Index = 1; Index = Index + 1; IF Index = 1 THEN DO; -- more ESQL -- END IF; IF VAR1 = 100 THEN DO; SET VAR1 = VAR1 + Index; END IF;
Related concepts
Message flows
Mappings
Related tasks
Developing message flow applications
Developing ESQL
Related reference
Built-in nodes
ESQL
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ak01010_ |