4. Elements of OpenSQL Statements : Operations : Arithmetic Operations : Default Type Conversion
 
Share this page                  
Default Type Conversion
When two numeric expressions are combined, the Enterprise Access product converts as necessary to make the data types of the expressions identical and assigns that same data type to the resulting expression. If it is necessary to convert the data type of an expression, the DBMS converts the expression having the data type of lower precedence to that of the higher.
The order of precedence among the numeric data types is, in highesttolowest order:
Money
Float
Real
Decimal
Integer
Smallint
For example, when OpenSQL operates on an integer and a floating-point number, the integer is converted to a floating-point number. If OpenSQL operates on two integers of different sizes, the smaller is converted to the size of the larger. All conversions are done before the operation is performed.
The following table summarizes the possible results of numeric combinations:
smallint
integer
decimal
real
float
money
smallint
integer
integer
decimal
real
float
money
integer
integer
integer
decimal
real
float
money
decimal
decimal
decimal
decimal
real
float
money
real
real
real
real
real
float
money
float
float
float
float
float
float
money
money
money
money
money
money
money
money
For example, for this expression:
(job.lowsal + 1000) * 12
the first operator (+) combines a float expression (job.lowsal) with a smallint constant (1000). The result is float. The second operator (*) combines the float expression with a smallint constant (12), resulting in a float expression.
For money data type, if the above table conflicts with Host DBMS default type conversion, Host DBMS default type conversion has higher priority.