4. Elements of QUEL Statements : Operations : Arithmetic : Default Type Conversion
 
Share this page                  
Default Type Conversion
When two numeric expressions are combined, the DBMS Server converts as necessary to make the data types of the expressions identical and assigns that data type to the result. The expression having the data type of lower precedence to that of the higher is converted. The order of precedence among the numeric data types is, in highest-to-lowest order:
money
float4
float
i4
i2
i1
For example, in an operation that combines an integer and a floating point number, the integer is converted to a floating point number. If the DBMS Server operates on two integers of different sizes, the smaller is converted to the size of the larger. The conversions are done before the operation is performed.
The following table lists the data types that result from combining numeric data types in expressions:
i1
i2
i4
float
float4
money
i1
i4
i4
i4
float
float4
money
i2
i4
i4
i4
float
float4
money
i4
i4
i4
i4
float
float4
money
float
float
float
float
float
float4
money
float4
float4
float4
float4
float4
float4
money
money
money
money
money
money
money
money
For example, for the expression
(job.lowsal + 1000) * 12
the first operator (+) combines a float4 expression (job.lowsal) with a i2 constant (1000). The result is float4. The second operator (*) combines the float4 expression with a i2 constant (12), resulting in a float4 expression.
To convert one data type to another you must use data type conversion functions. For details, see Data Type Conversion Functions.