HPlogo ALLBASE/SQL Pascal Application Programming Guide: HP 9000 Computer Systems > Chapter 3 Embedding SQL Commands

Declaring the SQLCA

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

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

Every ALLBASE/SQL Pascal main program must contain an SQLCA declaration in the global declaration part. The SQLCA should be a VAR parameter in a subprogram to which the main program passes the SQLCA.

NOTE: 300/400 Series 300 and Series 400 systems do not allow subprograms.

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

   EXEC SQL INCLUDE SQLCA;

When the preprocessor parses this command, it inserts the following type definition into the modified source code file:

   SQLCA: SQLCA_TYPE;

You can also declare the SQLCA explicitly as follows:

   SQLCA: SQLCA_TYPE;

The Pascal preprocessor generates a complete Pascal declaration for the SQLCA in SQLTYPE. The following seven fields in the SQLCA record are available for programmers to use:

   SQLCODE



   SQLERRD[3]                     SQLWARN[2]

   SQLWARN[0]                     SQLWARN[3]

   SQLWARN[1]                     SQLWARN[6]

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.

Feedback to webmaster