-
Variables are declared with “declare <type> <identifier>;” statement. Variables can only be declared in the main scope. Variable declarations within blocks (that is, statement blocks) are not allowed.
-
A variable declaration can contain an optional initializer. If none is specified, then the handler uses an appropriate default: 0 for numerics, zero length string for character, false for Boolean.
-
A variable should be defined before it is first referenced, and all variables should be defined at the beginning of a complex expression before executable statements.
-
The integer type (also int) should be used for all integer types (smallint, int, and long). In the code, a long is generated. This is meant to encompass short, integer, and long.
-
The double type should be used for all float, double, real types. In the code, a Java double is generated. This is meant to encompass float, double, and real.
-
The character type (also char) is used for character strings. Currently, unlike, character variables are variable in length; no length needs to be specified. In the code, a Java String is generated. This is meant to encompass character and varchar. Character values do not have an assigned length within the runtime Expression Handler. Any truncation that needs to take place is handled immediately after returning from the Expression Handler or in the apply component before updating the target column.
-
The boolean type is either true or false. In the code, a Boolean is generated.
The numeric values of 0 and 1 are often used to indicate the logical Boolean values of true or false, but they cannot be used in this way in an expression as Boolean constants. They are numeric values only. The Boolean constants for “false” and “true” that need to be used are:
-
false–no quotes of any kind for the Boolean constant false
-
true–no quotes of any kind for the Boolean constant true
-
The decimal type (also dec), like SQL, can have precision and an optional scale. If “DECIMAL” is specified, then this defaults to DECIMAL(9,0). Decimal can be specified with just precision (for example, “DECIMAL(5)”) or with precision and scale (for example,”DECIMAL(5,2)”). Decimal literals (for example, 1234.56) do not support commas as valid numeric punctuation: 1,234.56 gets a parse error. Also leading zeros in numerics are not supported (for example, 001234 will get a parse error). For more information, see Arithmetic Operations in the Expression Handler. The decimal type is implemented using BigDecimal.
-
Dates, times, or timestamps are not supported in the grammar as explicit types. That is, a variable cannot be defined as a date, time, or timestamp. These are handled as strings. Any transformation required for these types should be done in a system-defined method. See Dates, Times, and Timestamps.
To avoid some ambiguities that exist in SQL, the equals sign “=”, used in SQL for EQ, was not chosen as it is also used as the assignment operator. There are NO OVERLOADED operators in this grammar. The plus sign is used for addition of numerics only; to avoid ambiguity it was NOT used for character concatenation. Where a synonym for an operator (EQ, eq, ==) is useful, it has been defined.
-
The “for” initialization cannot include a variable declaration as is allowed in Java. The variable used here must be previously defined.
-
The “for” initialization statement and the “for” update statement cannot contain statement lists as is allowed in Java; only one statement is allowed.
-
Postfix increment (for example, --n) and decrement (for example, n++) operators are supported but the prefix (for example, n--) operators are not.
-
For the handling of NULL values see the Processing NULL Values in the Expression Handler.
-
All types of expressions currently must return a value. A void return is not allowed.
-
The return statement cannot itself return a statement; it must be an expression. The following is allowed: “return salary + bonus;”; the following is illegal: “return total = salary + bonus;”.
-
If comments within an expression are desired, use “C” style comments (/* */) to delimit text to be ignored by the parser. Double slash (//) comments are not currently supported.
-
The SQL predicates “<column> IS NULL” or “<column> IS NOT NULL” are supported and equivalent to “eq NULL” (equal) or “ne” (not equal) respectively.
-
Tokens or reserved words in the grammar are generally handled in a case-insensitive way: both “C1 eq 100” and “C1 EQ 100” parse successfully, but “C1 eQ 100” or “C1 Eq 100” fails.
-
The LIKE predicate only supports name operands with literals. That is, in the LIKE clause, the pattern and escape values must be literals; a value expression is not currently supported. The name operand on the left side must be a column or variable name; it cannot be an expression.
-
The In predicate only supports name operands with literals, as is the case with LIKE. See above.