IBM Books

Application Development Guide


SQLSTATE and SQLCODE Variables

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] 
    long  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 long SQLCODE;                                              
   extern char SQLSTATE[6];


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]