DB2 Server for VSE & VM: Application Programming


Handling SQL Errors

There are two ways to declare the return code structure (called SQLCA):

  1. You may write:
       EXEC SQL INCLUDE SQLCA
    

    in your source program. The preprocessor replaces this with the declaration of the SQLCA structure.

  2. You may declare the SQLCA structure directly, as shown in Figure 124.

    Figure 124. SQLCA Structure (in FORTRAN)

     INTEGER*4        SQLCOD,
    *                 SQLERR(6),
    *                 SQLTXL*2
     COMMON /SQLCA1/  SQLCOD,SQLERR,SQLTXL
     
     CHARACTER        SQLERP*8,
    *                 SQLWRN(0:10),
    *                 SQLTXT*70,
    *                 SQLSTT*5
     COMMON /SQLCA2/  SQLERP,SQLWRN,SQLTXT,SQLSTT
    

The SQLCA must not be declared within the SQL declare section. The meanings of the fields within the SQLCA are discussed in the DB2 Server for VSE & VM SQL Reference manual.

You may find that the only variable in the SQLCA you really need is SQLCODE. If this is the case, declare just the SQLCOD variable and invoke NOSQLCA support at preprocessor time.
Note:FORTRAN requires SQLCOD instead of SQLCODE.

The number of SQLCOD declarations is not limited by the preprocessor. If a stand-alone SQLCOD is specified, the code inserted by the preprocessor into the FORTRAN code to expand an EXEC SQL statement will refer to the address of that SQLCOD. The FORTRAN compiler determines if multiple declarations within a program section are not acceptable. In addition, the FORTRAN compiler determines which region of the code an SQLCOD declaration refers to.


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