ALLBASE/SQL Reference Manual (36216-90216)

Chapter 8 231
Expressions
Expression
Description
Arithmetic operators can be used between numeric values, that is, those with data
types of FLOAT, REAL, INTEGER, SMALLINT, or DECIMAL. Refer to the "Data
Types" chapter for rules governing the resulting precision and scale of DECIMAL
operations.
Arithmetic operators can also be used between DATE, TIME, DATETIME, and
INTERVAL values. Refer to the "Data Types" chapter for rules on the valid operations
and the resulting data types.
Elements in an expression are evaluated in the following order:
Aggregate functions and expressions in parentheses are evaluated first.
Unary plusses and minuses are evaluated next.
The * and / operations are performed next.
The + and operations are then performed.
You can enclose expressions in parentheses to control the order of their evaluation. For
example:
10 * 2 1 = 19, but
10 * (21) = 10
TO_INTEGER is the only date/time function that can be used in arithmetic
expressions.
When two primaries have the same data type, the result is of that data type. For
example, when an INTEGER is divided by an INTEGER, the result is INTEGER. In
such cases, the result will be truncated.
If either arithmetic operand is the NULL value, then the result is the NULL value.
Arithmetic operators cannot be used to concatenate string values. Use || to
concatenate string operands.
Both operands of concatenation operator should be one of the following: CHAR (or
VARCHAR, or Native CHAR, or Native VARCHAR), BINARY (or VARBINARY), but no
mix of CHAR and BINARY.
If either concatenation operand is the NULL value, then the result of the concatenation
is the NULL value.
If one concatenation operand is a variable length string (VARCHAR, Native VARCHAR,
VARBINARY), then the result data type of the concatenation is a variable length string.
If both concatenation operands are fixed length string data type (CHAR, Native CHAR,
BINARY), then the result of the concatenation is fixed length string.
The concatenation result will consist of the first operand followed by the second
operand. The trailing blanks of the string value are preserved by concatenation
regardless of the string's data types. The resultant string may be truncated on the
right, if the length exceeds the maximum string length of 3996 bytes. If truncation
occurs, a truncation warning is sent.
Type conversion, truncation, underflow, or overflow can occur when some expressions