Dynamic SQL - Teradata Preprocessor2

Teradata® Preprocessor2 for Embedded SQL Programmer Guide

Product
Teradata Preprocessor2
Release Number
17.00
Published
June 2020
Language
English (United States)
Last Update
2020-06-19
dita:mapPath
whb1544831946911.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

C supports dynamic SQL, and the application must contain the necessary SQL Descriptor Area (SQLDA) structures.

The SQLSTATE and SQLCODE variables are documented in “Result Code Variables” in Teradata Vantage™ - SQL Stored Procedures and Embedded SQL , B035-1148 .

Include an SQLDA structure in one of the following ways:
  • Embed EXEC SQL INCLUDE SQLDA; the statement in the application causes PP2 to generate the structure.
  • Code the SQLDA directly into the program using any name.

The generated SQLDA structure for a C program is:

#ifndef SQLDASIZE {
   struct sqlda {
      unsigned char sqldaid[8];
      int sqldabc;
      short sqln;
      short sqld;
      struct sqlvar {
         short sqltype;
         unsigned short sqllen;
         unsigned char *sqldata;
         short *sqlind;
         struct sqlname {
            short length;
            unsigned char data[30];
            } sqlname;
         } sqlvar[1];
      };
#define SQLDASIZE(n)\
(sizeof(struct sqlda) + ((n)-1)*sizeof(struct sqlvar)
#endif

The second example dynamic program at the end of this section shows how to use the INCLUDE SQLDA statement.