Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 14:- Database Interface


  • SQLCA stands for SQL Communication Area and it is DB2 system provided copybook.
  • SQLCA has multiple Host variables defined to hold the information about last executed SQL statement
  • All host variables get updated after the execution of each SQL statement.
  • Thus, every COBOL program containing Embedded SQL statements must have SQLCA included in WORKING-STORAGE SECTION.
  • Syntax:-


  • This copybook provide capability to COBOL program to check whether last query execution was successful or not. This can be done by examining the value contained in SQLCODE host variable.
  • SQLCODE = ‘000’ indicates successful execution of last SQL statement.
  • There is one more important host variable “SQLERRD(3)” which is used to hold number of rows affected by last SQL statement
  • Information held by SQLCA host variable enable us to: -
    • Debug our code. Using debugger one can view the SQLCA fields and examine its error codes and warning flags. We can also display SQLCA fields value in SYSOUT to debug.
    • Control flow of our program by testing its values. For example, if SQLCODE indicates error, we can call error-processing paragraph.

© copyright mainframebug.com
Privacy Policy