15.10 - Varying Character Data - 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

The C language does not have a natural varying character data type. However, PP2 allows the definition of a varying character field using the special identifier, VARCHAR.

PP2 converts this designation to a structure composed of two fields.

VARCHAR  var1[n];

becomes:

struct
      {
       SQLInt16  len;
       char arr[n];
      }var1;

SQLInt16 is a defined constant equivalent to short and n is an integer value > 0 (n reflects the maximum length of the data to be sent or received: Do not add +1 for a terminating null).

This type of field can contain characters or binary data, including '\0' terminating null characters.

Varying character fields do not contain a terminating null character ('\0').

The len field contains the length of the data returned to the arr portion. Let M be the length of the returned data.

 

Value

Description

M = n

  • The data is moved to arr with no exception conditions
  • len is set to M
  • M < n

  • M characters of data are moved to arr
  • len is set to M
  • M > n

  • n characters are moved to arr
  • len is set to n
  • SQLWARN1 in SQLCA is set to W
  • The indicator variable (if present) is set to M
  • Varying character data has a type of 448 (449 if nullable), with a maximum length of n.

    DATE values can be returned to this type of field, provided the length is sufficient to hold the format chosen at precompile time. See “DATE(D|E|I|J|U) -d D|E|I|J|U” on page 71.