HP 3000 Manuals

Declaring the SQLCA [ ALLBASE/SQL COBOL Application Programming Guide ] MPE/iX 5.0 Documentation


ALLBASE/SQL COBOL Application Programming Guide

Declaring the SQLCA 

The SQLCA is an ALLBASE/SQL data structure that contains current
information about a program's DBE session.

Every ALLBASE/SQL COBOL program must contain an SQLCA declaration.  When
a program or subprogram starts a DBE session, the SQLCA declaration must
be in its WORKING-STORAGE SECTION. If a subprogram called by such a
program contains SQL commands to be executed in the same DBE session, the
SQLCA declaration must also appear in the LINKAGE SECTION of the
subprogram.

As shown in Figure 3-1  at  1 , you can declare the SQLCA by using the
INCLUDE command:

          EXEC SQL INCLUDE SQLCA END-EXEC.

When the preprocessor encounters this command, it generates a complete
COBOL declaration for this area.  Six of the fields in the SQLCA record
are available for programmers to use:

               SQLCODE
               SQLERRD(3)
               SQLWARN1
               SQLWARN2
               SQLWARN0
               SQLWARN6

Some values ALLBASE/SQL places into these fields indicate warning and
error conditions that resulted when the immediately preceding SQL command
was executed.  Other values simply provide information attendant to
normal command execution but are programmatically useful.  For example,
when you submit an UPDATE command, the number of rows updated is placed
in SQLERRD(3).  If this value is greater than one, the program may want
to advise the user of that condition and process a ROLLBACK WORK or
COMMIT WORK command based on the user's response.

Examples discussed later in this chapter under "Implicit Status Checking"
and "Explicit Status Checking" illustrate how the program in Figure 3-1
 uses some of the SQLCA fields to determine the success or failure of
SQL command execution.



MPE/iX 5.0 Documentation