Converting datatypes

The precompiler automatically compares the datatypes of host variables with the datatypes of table columns in Adaptive Server. If the Adaptive Server datatype and the host language datatype are compatible but not identical, the precompiler converts one type to the other. Datatypes are compatible if the precompiler can convert the data from one type to the other. If the datatypes are incompatible, a conversion error occurs at runtime and sqlcode is set to <0.

Be careful when converting a longer datatype into a shorter one, such as a 4-byte into 2-byte, because there is always a possibility of truncating data. If a truncation occurs, sqlwarn1 is set to “W.”