A literal is a direct representation of a value. Enclose character
literals in quotation marks. Numeric variables consist of numerals,
and can also include a decimal point, a plus or minus sign, or the
letter "E" (in the case of floating point literals). The following
examples show numeric literals in assignment statements. For more
about assigning values to variables, see
Assignments:
- myInt INT = 9;
- myDecimal DECIMAL(6,2) = -256.23;
- myFloat FLOAT = 2.539E7;
The last example, 2.539E7, is shorthand for 2.539 x 10**7, or 25,390,000.
The following table shows the assumptions that EGL makes about
the type of a numeric literal:
Table 1. Types of numeric literalsNumber of digits |
Decimals? |
Exponent |
Assumed type |
1-4 |
N |
N |
SMALLINT |
5-9 |
N |
N |
INT |
10-18 |
N |
N |
BIGINT |
x (where x>18) |
N |
N |
NUM(x) |
x (with y decimal places) |
Y |
N |
DECIMAL(x,y) |
any |
either |
Y |
FLOAT |
Character literals can also include a one-letter prefix, as shown
in the following examples. You might need this prefix when using a
literal as an argument in a function call, or in a transfer of control
that requires a particular type. For an explanation of these types,
see
Primitive data types:
- C
- Indicates a CHAR value. C"ABC" is a CHAR(3).
- M
- Indicates an MBCHAR value. M"ABC" is an MBCHAR(3).
- D
- Indicates a DBCHAR value. D"ABC" is a DBCHAR(3),
assuming A, B, and C are double-byte characters.
- X
- Indicates a HEX value. X"AB" is a HEX(2) specifying
one byte, 1010 1011 in binary.
In addition, the following two-letter prefixes are available to
indicate a hexadecimal codepoint for an unprintable character, such
as Ctrl+L, the form-feed character in both ASCII and EBCDIC:
- CX
- CX"0C" is a CHAR(1) containing a form-feed character.
- MX
- MX"0C" is an MBCHAR(1) containing a form-feed character.
- DX
- DX"8F41" is an example of a DBCHAR(1); if you use code page 949,
it represents a Korean character. (DBCHAR literals or variables cannot
contain single-byte data like hex 0C.)
- UX
- UX"000C" is a UNICODE(1) containing a form-feed character.
The following details apply to character literals:
- With no prefix, a character literal is a STRING type.
- There is no UNICODE literal with just a U prefix. There is only
the UX prefix for UNICODE literals.
- There is no way to indicate a hexadecimal codepoint for a STRING.
In addition to numeric and character literals, EGL also provides
array literals. For more on that subject, see Arrays.
Compatibility
Table 2. Compatibility considerations
for literalsPlatform |
Issue |
JavaScript generation |
The following types (including literals, as
appropriate) are not supported: ArrayDictionary, BIN (with decimal
places), BLOB, CHAR, CLOB, DBCHAR, HEX, INTERVAL,
MBCHAR, NUMC, STRING (with a size limit), PACF, UNICODE, and structured
Record parts. |