Databases Reference
In-Depth Information
4.3.9 The SQL Communications Area (SQLCA)
The SQL Communications Area (SQLCA) is a DB2 data structure useful in
obtaining information pertaining to the processing of an SQL statement or an API
call.
As the SQLCA is updated by the database manager after each SQL statement, it
is important we examine the structure to ensure that any unexpected errors will
be handled by the application.
The SQLCA structure provides important information such as:
SQLCODE:
This is an integer return code indicating whether the most recent SQL
statement processed was successful or not. The value is 0 if successful, 100
if a query yields no results, positive if a warning occurred, and negative if the
processing was unsuccessful and an error was returned.
SQLSTATE:
This is a five digit character length field that contains a return code from the
last SQL statement processed. The return code is consistent with the SQL
Standard.
SQLERRD:
This is an integer array containing six pieces of information related to the last
SQL statement processed that can be useful when an error occurs.
To define the SQLCA, we can add the following statement to our program:
EXEC SQL INCLUDE SQLCA;
Alternatively, we can include the SQLCA header file and use it to declare an
application variable:
#include <sqlca.h>
struct sqlca mySqlca;
If we had additional source files, we can add the following lines to the other
source files:
#include <sqlca.h>
extern struct sqlca sqlca
Search WWH ::




Custom Search