15.10 - ANSI-Compatible Mode Communications Variables - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

prodname
Preprocessor2 for Embedded SQL
vrm_release
15.10
category
Programming Reference
featnum
B035-2446-035K

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 character SQLSTATE 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 SQL Stored Procedures and Embedded SQL (B035‑1148).