Array Support - 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

The array insert feature for network and mainframe environments improves application performance by allowing iterative requests to be grouped together into a single step, resulting in a decrease of the step-processing overhead per request. Only single INSERT statements and references to arrays of variables are supported. References to arrays of structures are not supported.

To accommodate this feature, the EXEC SQL statement is modified to:

EXEC SQL FOR (<countval) <sql statement string>;

where:

  • FOR indicates that this is an array statement
  • <countval> is a user defined integer variable or literal integer constant that must be less than or equal to the smallest defined dimension in the list of arrays
    Ensure that <countval> does not exceed the smallest defined dimension in the list of arrays. An error is generated if this condition is violated and countval is specified as a literal. At precompile time, no check is made when countval is specified as a variable.
  • <sql statement string> is a character string containing a legal SQL statement with references to host variables

Literal integer constants that are embedded in the SQL string are not iterated; they are propagated in every inserted row.

The same host variable can be specified for two or more fields. Any given iteration will obtain the same value.

Example

EXEC SQL BEGIN DECLARE SECTION;
char empname[50][20];
long empnum[50];
float empsal[50];
long cNewEmployees = 50;
short e_nameind = 0, e_numind =0, e_salind =-1;
EXEC SQL END DECLARE SECTION;
EXEC SQL PREPARE exInsert01 FROM insert into employee values (?, ?, ?);
EXEC SQL FOR cNewEmployees
EXECUTE exInsert01 USING :empname, :empnum, :empsal;