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


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−

EXEC SQL
INCLUDE SQLCA
END-EXEC

Updated on: 14-Sep-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements