Preprocessor2 can return program status and error information to applications in multiple ways.
The primary communication method for applications written to run in Teradata session mode has been the SQLCA structure. SQLCA is a data structure that contains a list of return codes and other status information about a completed DML statement.
- Result reporting
- Warning condition reporting
- Support for DSNTIAR
Embedded SQL application programs can interrogate the fields of SQLCA for the return codes that indicate the results of having run an embedded SQL statement.
Embedded SQL applications can also retrieve full diagnostic text by using a supplied routine (see PPRTEXT).
SQLCA cannot be used with stored procedures.
ANSI Compliance
The SQL Communications Area and the INCLUDE SQLCA statement are not ANSI-SQL compliant. When set to ANSI, the preprocessor TRANSACT or -tr option flags INCLUDE SQLCA as an error.
ANSI mode applications report program status and errors by means of the SQLSTATE and SQLCODE status variables (see SQLSTATE Mappings for information about mapping SQLCODE and SQLSTATE variables to each other and to database error messages).
The ANSI/ISO SQL-92 standard explicitly deprecates SQLCODE. The ANSI/ISO SQL-99 standard no longer defines SQLCODE. Use SQLSTATE when writing stored procedures and embedded SQL applications to run in ANSI transaction mode. You can also use SQLSTATE in your stored procedures and embedded SQL applications written to run in Teradata transaction mode.
When you are developing stored procedures or embedded SQL applications in the ANSI environment, use the status variable SQLSTATE in place of SQLCA and define SQLSTATE explicitly in your code. See SQLSTATE Result Code Variable, SQLCODE Result Code Variable and SQLSTATE Mappings for further information.