Error Information from SQLCA
The SQL Communications Area (SQLCA) is a collection of host language variables whose values provide status and error information about embedded OpenSQL database statements. (The status of forms statements is not reflected in SQLCA variables.) If your application does not have an SQLCA, the default is to display errors and continue with the next statement if possible.
Two variables in the SQLCA contain error information: sqlcode and sqlerrm. The value in sqlcode indicates one of three conditions:
• Success - Sqlcode contains zero.
• Error - Sqlcode contains the error number as a negative value.
• Warning - (Set when the statement executed successfully but an exceptional condition occurred.) Sqlcode contains +100, indicating that no rows were processed by a DELETE, FETCH, INSERT, UPDATE, MODIFY, COPY, or CREATE TABLE...AS statement.
The sqlerrm variable is a varying length character string variable that contains the text of the error message. The maximum length of sqlerrm is 70 bytes. If the error message exceeds that length, OpenSQL truncates the message when it assigns it to sqlerrm. To retrieve the full message, use the
INQUIRE_SQL statement (see page
The Inquire_sql Statement--Retrieve Runtime Information). In some host languages, this variable has two parts: sqlerrml, a 2-byte integer indicating how many characters are in the buffer, and sqlerrmc, a 70-byte fixed length character string buffer.
The SQLCA also contains eight 1-byte character variables, sqlwarn0 ‑ sqlwarn7, that are used to indicate warnings. These variables are described in
The SQL Communications Area (SQLCA) (see page
The SQL Communications Area (SQLCA)).
The SQLCA is often used in conjunction with the WHENEVER statement, which defines a condition and an action to take whenever that condition is true. The conditions are set to true by values in the sqlcode variable. For example, if sqlcode contains a negative error number, then the sqlerror condition of the WHENEVER statement is true, and any action specified for that condition is performed.
You can also access the SQLCA variables directly. For information about implementing the SQLCA in an application and using its variables, see the Embedded SQL Companion Guide.