ALLBASE/SQL Reference Manual (36216-90216)

214 Chapter7
Data Types
Type Conversion
Truncation of the fractional part of a value occurs during these conversions:
DECIMAL to SMALLINT or INTEGER
DECIMAL to DECIMAL when the target scale is smaller than the source scale
FLOAT to INTEGER, SMALLINT, DECIMAL, or REAL
REAL to INTEGER, SMALLINT, or DECIMAL
Truncation can occur during these conversions if the target is too small:
DATE, TIME, DATETIME or INTERVAL to VARCHAR or CHAR
CHAR to VARCHAR, BINARY or VARBINARY
VARCHAR to CHAR, BINARY or VARBINARY
VARBINARY to BINARY, CHAR or VARCHAR
BINARY to VARBINARY, CHAR, or VARCHAR
When you use numeric data of different types in an expression or comparison operation,
the data type of the lesser type is converted to that of the greater type, and the result is
expressed in the greater type. Numeric types have the following precedence:
FLOAT
REAL, DECIMAL
INTEGER
SMALLINT
Comparison operations or expressions involving different numeric data types result in
conversion from one data type to another as explained in Table 7-4.
Table 7-4. Conversions from Combining Different Numeric Data Types
Operations containing: Result:
DECIMAL and INTEGER
types only
All participating integers are converted to DECIMAL quantities
having a precision of 10 and a scale of 0.
DECIMALandSMALLINT
types only
All participating SMALLINT values are converted to DECIMAL
quantities having a precision of 5 and a scale of 0.
One item of type FLOAT All participating integer and decimal operands are converted to
FLOAT quantities and precision can be lost.
One item of type REAL All arithmetic involving REAL operands results in a type of
FLOAT. All participating integer and decimal operands are
converted to FLOAT quantities and precision can be lost.