SQL Communications Area [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
SQL Communications Area
After any SQL statement has executed, important information is returned
to the program in an area called the SQL Communication Area (SQLCA).
There is a status indicator in a field of the SQLCA called SQLCODE and,
if your system supports it, SQLSTATE. SQLCODE is a numeric data item (PIC
S9(9) COMP-5) which contains the result of the SQL operation. A value of
zero means that the statement has executed successfully; a positive value
means the statement did execute, but that some exceptional condition
occurred; and a negative value means that an error occurred and the
statement did not complete successfully. SQLSTATE is defined as a five
character data item (PIC X(5)) and is provided for compatibility with the
ANSI SQL2 database language definition.
The SQL Communication Area is usually included in your program by the
statement :
EXEC SQL INCLUDE SQLCA END-EXEC
This causes the source file SQLCA.CPY to be included in your source code.
This source file, available with this system, contains a COBOL definition
of the SQLCA.
If you do not include this statement, an area is allocated automatically
by the compiler, but is not addressable within your program. If you do,
however, declare either or both of SQLCODE and SQLSTATE, the COBOL
compiler generates code to copy the corresponding fields in the SQLCA
area to the user defined fields after each EXEC SQL statement. It is
preferable to define the entire SQLCA. (This facility is provided for
ANSI compatibility.)
If you do include the INCLUDE SQLCA statement, the file SQLCA.CPY must be
available at compile time.
After any non-zero condition in SQLCODE, the compiler updates the
contents of the data item MFSQLMESSAGETEXT with a description of the
exception condition, provided it has been defined. If it is, it must be
declared as a character data item (PIC X(n), where n can be any legal
value; if the message does not fit into the data item it is truncated).
None of SQLCA, SQLCODE, SQLSTATE and MFSQLMESSAGETEXT are required to be
declared as host variables.
MPE/iX 5.0 Documentation