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 COBOL veneer layer 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 or SQLSTATE is set to a negative number.

Be careful when converting a longer datatype into a shorter one, such as a long integer into PIC S9(4) COMP, because there is always a possibility of truncating data. If a truncation occurs, SQLWARN1 is set.

NoteDo not fetch Adaptive Server data into COBOL numeric fields that contain editing characters such as commas and decimal characters. Instead, fetch the data into an unedited field such as comp or display sign leading separate and then move the data into an edited field.