The SQLWARN3 field in SQLCA is used to detect the condition wherein the number of the resultant columns is greater than the number of host variables given in the query of a COBOL-DB2 program. The SQLWARN3 is a 1 byte field, which contains the value ‘W’when there is mismatch in number of columns returned by the query and number of host variables used.
We can enquire the status of SQLWARN3 using IF or EVALUATE statements as in the below example
A010-CHECK-ORDER. EXEC SQL SELECT ORDER_DATE, ORDER_TOTAL INTO :ORDER-DATE, FROM ORDERS WHERE ORDER_ID = :ORDER-ID END-EXEC EVALUATE SQLWARN3 WHEN ‘W’ DISPLAY ‘MISMATCH IN COLUMNS & HOST VARIABLES’ WHEN OTHER DISPLAY ‘QUERY EXECUTED SUCCESSFULLY’