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 highest‑to‑lowest 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:
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.