DB2 10.5 for Linux, UNIX, and Windows

SQLSTATE and SQLCODE variables in C and C++ embedded SQL application

Your embedded SQL application can declare the SQLCODE and SQLSTATE variables to handle errors or help you debug your embedded SQL application.
When using the LANGLEVEL precompile option with a value of SQL92E, the following two declarations can be included as host variables:
  EXEC SQL BEGIN DECLARE SECTION;
    char      SQLSTATE[6] 
    sqlint32  SQLCODE; 

    
  EXEC SQL END DECLARE SECTION;

The SQLCODE declaration is assumed during the precompile step. Note that when using this option, the INCLUDE SQLCA statement must not be specified.

In an application that is made up of multiple source files, the SQLCODE and SQLSTATE variables can be defined in the first source file as in the previous example. Subsequent source files should modify the definitions as follows:
   extern sqlint32 SQLCODE;                                              
   extern char     SQLSTATE[6];