As DB2/SQL and COBOL field declarations are different, It is important to have Equivalanet COBOL data types to the corresponding DB2 table columns in COBOL programs to process the data correctly. More importantly, the precompiler uses the equivalent SQL data types for the declared Host variables. So if the host variable declaration is not correct, we might face issues while executing the programs.
Below are the compatible COBOL and SQL data types.
Special care needs to be taken while processing the VARCHAR data in host programs. A group variable consisting of Length and Actual variable as the sub fields needs to be declared. Without the length variable, data gets truncated and inappropriate results encounter.