ALLBASE/SQL Reference Manual (36216-90216)
Chapter 7 213
Data Types
Type Conversion
Type Conversion
ALLBASE/SQL converts the type of a value in the following situations:
• Including values of different types in the same expression.
• Moving data from a host variable to a column or a column to a host variable of a
different type.
The valid type combinations are shown in Table 7-1.
In some cases, such as the following, data conversion can lead to overflow or truncation:
• Overflow can occur during these conversions:
FLOAT to DECIMAL, INTEGER or SMALLINT
FLOAT to REAL
REAL to DECIMAL, INTEGER, or SMALLINT
DECIMAL to DECIMAL, INTEGER, or SMALLINT
INTEGER to DECIMAL or SMALLINT
SMALLINT to DECIMAL
• Overflow of the integer part and truncation of the fractional part of a number can occur
during a FLOAT-to-DECIMAL conversion, because ALLBASE/SQL aligns the decimal
points.
Table 7-3. Valid Type Combinations
Source Data Type Target Data Type
CHAR or VARCHAR CHAR or VARCHAR
DATE, TIME DATETIME, or INTERVAL when
CHAR value involved in date/time math or inserted
into or compared to a date/time column
CHAR or VARCHAR BINARY or VARBINARY (from host
variable/constant into a binary column only)
BINARY or VARBINARY BINARY or VARBINARY
BINARY or VARBINARY CHAR or VARCHAR (from column into host
variable, or comparing a binary column with a char
column or value)
DECIMAL, FLOAT, REAL, INTEGER,
SMALLINT
Any numeric type
DATE, TIME, DATETIME, INTERVAL CHAR or VARCHAR (except in LIKE predicate)