When writing C programs for ANSI mode, defining a SQLCODE variable is required. Defining a SQLSTATE variable is optional. If both variables are defined, each contains valid error codes.
Do not use the INCLUDE SQLCA construct when writing applications for ANSI mode. Instead, replace that construct with either SQLSTATE or a SQLCODE.
Declare SQLCODE as a 32-bit signed integer. Declare SQLSTATE as a fixed length 6 character array to hold the 5 characterSQLSTATE code plus the null terminator.
Example: Declare Variables for a C Application
EXEC SQL BEGIN DECLARE SECTION; int SQLCODE; char SQLSTATE[6]; EXEC SQL END DECLARE SECTION;
SQLSTATE and SQLCODE are documented in “Result Code Variables” in Teradata Vantage™ - SQL Stored Procedures and Embedded SQL, B035-1148.