Application Development Guide


SQLSTATE and SQLCODE Variables in C and C++

When using the LANGLEVEL precompile option with a value of SQL92E, the following two declarations may be included as host variables:

  EXEC SQL BEGIN DECLARE SECTION;
    char      SQLSTATE[6] 
    sqlint32  SQLCODE; 
 
    
·
·
·
EXEC SQL END DECLARE SECTION;

If neither of these is specified, the SQLCODE declaration is assumed during the precompile step. Note that when using this option, the INCLUDE SQLCA statement should not be specified.

In an application that is made up of multiple source files, the SQLCODE and SQLSTATE variables may be defined in the first source file as above. Subsequent source files should modify the definitions as follows:

   extern sqlint32 SQLCODE;                                              
   extern char     SQLSTATE[6];


[ Top of Page | Previous Page | Next Page ]