ANSI-Compatible Mode Communications Variables - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

Product
Preprocessor2 for Embedded SQL
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

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).