How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?

DB2DatabaseBig Data Analytics

SQLCA stands for SQL-Communication Area. It is a medium through which DB2 can communicate with the COBOL program. In a typical COBOL-DB2 program, there are many SQL statements used. The main purpose of SQLCA is to inform the COBOL program about the status and other details of the most recently executed SQL query.

The SQLCA has a total length of 136 bytes and it is composed of various fields like SQLCODE, SQLERRD, SQLWARN, etc. Each of these fields give specific details of the last executed SQL query.

For example, SQLCODE returns the DB2 error code (if any), SQLWARN returns the warning issued while executing SQL statements.

The SQLCA is declared in COBOL working storage area with INCLUDE statement as below−

Published on 14-Sep-2020 14:19:07