SQL/MP Programming Manual for COBOL

Error and Status Reporting
HP NonStop SQL/MP Programming Manual for COBOL529758-003
9-12
Returning Information From the SQLCA
Returning Information From the SQLCA
SQL/MP returns run-time information, including errors and warnings, for the most
recently executed SQL statement to the SQL communication area (SQLCA). The
SQLCA structure can contain up to seven error or warning codes (in any combination)
that might be returned by a single SQL statement or directive.
Declaring the SQLCA Structure
The HP COBOL compiler does not automatically generate an SQLCA structure. You
must explicitly declare an SQLCA structure using an INCLUDE SQLCA directive in the
Data Division of your program. To declare an SQLCA structure, specify the
INCLUDE SQLCA directive using this syntax (if you do not first specify the
INCLUDE STRUCTURES directive, SQL/MP generates version 2 structures by
default):
Using System Procedures With the SQLCA Structure
The SQL system procedures are written in TAL, but you can call them from a COBOL
program using an ENTER TAL statement. Use the SQL system procedures to return
SQLCA information:
For more information, see Section 5, SQL/MP System Procedures
.
Table 9-1 on page 9-13 describes the SQLCA fields generated by the INCLUDE
SQLCA directive. Do not access the SQLCA fields directly. HP reserves the right to
change the SQLCA fields in future PVUs.
EXEC SQL INCLUDE SQLCA END-EXEC.
System Procedure Description
SQLCA_DISPLAY2_ Writes SQL error and warning messages from the SQLCA
structure to a file or terminal
SQLCAGETINFOLIST Writes a specified subset of the SQL error or warning
information from the SQLCA structure to a record area in the
program
SQLCA_TOBUFFER2_ Writes SQL error or warning messages from the SQLCA
structure to a record area in the program
SQLCAFSCODE Returns information about file-system, disk-process, or
operating system errors returned to the program