Numeric Literals
Numeric literals specify numeric values. There are three types of numeric literals:
• Integer
• Decimal
• Floating-point
A numeric literal can be assigned to any of the numeric data types or the money data type without using an explicit conversion function. OpenSQL automatically converts the literal to the appropriate data type, if necessary.
By default, OpenSQL uses the period (.) to indicate the decimal when needed. This default can be changed by setting II_DECIMAL. For information about setting II_DECIMAL, see the Database Administrator Guide.
Note: If II_DECIMAL is set to comma, be sure that when OpenSQL syntax requires a comma (such as a list of table columns or OpenSQL functions with several parameters), that the comma is followed by a space. For example:
select col1, ifnull(col2, 0), left(col4, 22) from t1:
Integer Literals
Integer literals are specified by a sequence of up to 10 digits and an optional sign, in the following format:
[+|‑] digit {digit} [e digit]
Integer literals are represented internally as either an integer or a smallint, depending on the value of the literal. If the literal is within the range ‑32,768 to +32,767, it is represented as a smallint. If its value is within the range ‑2,147,483,648 to +2,147,483,647 but outside the range of a smallint, then it is represented as an integer. Values that exceed the range of integers are represented as decimals.
Integers can be specified using a simplified scientific notation, similar to the way floating-point values are specified. To specify an exponent, follow the integer value with the letter “e” and the value of the exponent. This notation is useful for specifying large values. For example, to specify 100,000 use the following exponential notation:
1e5
Decimal Literals
Decimal literals are specified as signed or unsigned numbers of 1 to 39 digits that include a decimal point. The precision of a decimal number is the total number of digits, including leading and trailing zeros. The scale of a decimal literal is the total number of digits to the right of the decimal point, including trailing zeros. Decimal literals that exceed 39 digits are treated as floating-point values.
Examples of decimal literals are:
3.
‑10.
1234567890.12345
001.100
Last modified date: 08/28/2024