SQLSTATE and SQLCODE variables in FORTRAN embedded SQL application
To handle errors or
debug your embedded SQL application, you should test the values of
the SQLCODE or SQLSTATE variable. You can return these values as output
parameters or as part of a diagnostic message string, or you can insert
these values into a table to provide basic tracing support.
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;
CHARACTER*5 SQLSTATE
INTEGER SQLCOD
.
.
.
EXEC SQL END DECLARE SECTION
The SQLCOD
declaration is assumed during the precompile
step. The variable named SQLSTATE
can also be SQLSTA
.
Note that when using this option, the INCLUDE SQLCA statement should
not be specified.
For applications that contain multiple source files, the declarations
of SQLCOD
and SQLSTATE
can be included
in each source file, as shown previously.