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 |
|
M < n |
|
M > n |
|
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.