SQLCA
SQL communication area: the block of fields DB2 fills in after every SQL statement, including SQLCODE.
Also written SQL communication area, EXEC SQL INCLUDE SQLCA, SQLERRD, SQLERRM, SQLWARN, DSNTIAR
The SQLCA, or SQL communication area, is how DB2 reports back to a program after each SQL statement. A COBOL program includes it with EXEC SQL INCLUDE SQLCA END-EXEC in WORKING-STORAGE, and DB2 updates it every time.
The best-known field is SQLCODE: zero for success, 100 for no row found, and a negative number for an error. SQLSTATE gives a standard five-character code for the same result. SQLERRM holds tokens that fill in the error message, such as a table name. SQLERRD is a small array, and its third entry gives the number of rows affected by an INSERT, UPDATE or DELETE. SQLWARN holds warning flags.
Programs check SQLCODE after each statement and decide what to do. For unexpected errors, many sites call a routine named DSNTIAR, which turns the SQLCA into readable message lines for the job output.
When you read a DB2 error in a job log, it usually came from a program displaying fields of the SQLCA, so knowing the fields helps you understand what the program was trying to tell you.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- SQLCODEThe result code DB2 returns after every SQL statement, saying whether it worked and what happened if it did not.
- Embedded SQLSQL statements written directly inside a COBOL program, marked off so they can be prepared before compiling.
- CursorA mechanism for stepping through a set of rows one at a time, when a query returns more than one result.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- WORKING-STORAGEThe section of a COBOL program that declares its internal variables: counters, totals, flags and work areas.