DB2 Version 9.7 for Linux, UNIX, and Windows

Implicit casting simplifies application enablement

Version 9.7 introduces support for implicit casting. Implicit casting is the automatic conversion of data of one data type to data of another data type based on an implied set of conversion rules. This automatic conversion occurs in support of weak typing.

Prior to Version 9.7, strong typing was used during comparisons and assignments. Strong typing requires matching data types, which means that you must explicitly convert one or both data types to a common data type before performing comparisons or assignments.

In Version 9.7, the rules used during comparisons and assignments have been relaxed. If two objects have mismatched types, implicit casting is used to perform comparisons or assignments if a reasonable interpretation of the data types can be made. Implicit casting is also supported during function resolution. When the data types of the arguments of a function being invoked cannot be promoted to the data types of the parameters of the selected function, the data types of the arguments are implicitly cast to the data types of the parameters. For more information, see "Functions".

Implicit casting reduces the amount of SQL statements that you must modify when enabling applications that run on data servers other than DB2 data servers to run on DB2 Version 9.7. In many cases, you no longer have to explicitly cast data types when comparing or assigning values with mismatched data types.

You can use the implicitcasting.db2 and the ImplicitCasting.java sample programs to learn how to use this feature.

Version 9.7 includes another enhancement that enables you to use untyped parameter markers and untyped NULL keywords almost anywhere in an SQL statement where you can use an expression. For more information, see "Determining data types of untyped expressions".