The SQLCA and message vector are two separate host structures
that SQL declares when it precompiles an INCLUDE SQLCA statement.
Both the SQLCA and the message vector provide ways of handling
errors:
o The SQLCA is a collection of parameters that SQL uses to
provide information about the execution of SQL statements
to application programs. The SQLCODE parameter in the SQLCA
shows if a statement was successful and, for some errors, the
particular error when a statement is not successful.
To illustrate how the SQLCA works in applications, interactive
SQL displays its contents when you issue the SHOW SQLCA
statement.
o The message vector is also a collection of parameters that
SQL updates after it executes a statement. It lets programs
check if a statement was successful, but provides more detail
than the SQLCA about the type of error if a statement is not
successful. The message vector, for example, provides a way to
access any follow-on messages in addition to those containing
the facility code RDB or SQL.
You can use the following steps to examine the message
vector:
- Assign any value to the logical name SQL$KEEP_PREP_FILES.
- Precompile any program that contains the line "EXEC SQL
INCLUDE SQLCA". (You can use the programs in the sample
directory.)
- Examine the generated host language program.
SQL updates the contents of the SQLCA and the message vector
after completion of every executable SQL statement (nonexecutable
statements are the DECLARE, WHENEVER, and INCLUDE statements).
You do not have to use the INCLUDE SQLCA statement in programs.
However, if you do not, you must explicitly declare the SQLCODE
parameter to receive values from SQL. SQLCODE is explicitly
declared as an unscaled, signed longword integer.
SQLCODE is a deprecated feature of the ANSI/ISO SQL standard
and is replaced by SQLSTATE. To comply with the ANSI/ISO
SQL standard, you should explicitly declare either SQLCODE
or, preferably, SQLSTATE instead of using the INCLUDE SQLCA
statement. SQLCA (and the INCLUDE SQLCA statement) is not part
of the ANSI/ISO SQL standard. If you declare SQLCODE or SQLSTATE
but use the INCLUDE SQLCA statement, SQL uses the SQLCA.
Programs that do not use the INCLUDE SQLCA statement will
not have the message vector declared by the precompiler. Such
programs must explicitly declare the message vector if they:
o Use the RDB$LU_STATUS field of the message vector in their
error checking
o Use system calls such as SYS$PUTMSG
The message vector is not part of the ANSI/ISO SQL standard.
When the SQLCA structure is explicitly declared by a program,
SQL does not update the SQLERRD fields. If you want the SQLERRD
fields updated, include the SQLCA definitions in the program
using the EXEC SQL INCLUDE SQLCA statement.
See the Oracle Rdb SQL Reference Manual for more information.