Entering content frame

 VARCHAR 

Use

You can use the predefined data type VARCHAR to declare host variables to which you want to assign character strings with variable lengths.

The C/C++ precompiler converts the VARCHAR declaration into a structure declaration with a two-byte length and an array or pointer. The current length of a VARCHAR variable is determined by the length field. NULL bytes do not contribute to the calculation of the length. In a VARCHAR declaration with pointer declarer, the application program is responsible for assigning memory at runtime.

VARCHAR v [n];

is replaced by

struct {unsigned short len; unsigned char arr [n];} v;

where the current length of the character string is assigned to len and the characters themselves are assigned to arr.

VARCHAR *v;

is replaced by

struct {unsigned short len; unsigned char arr [1];} *v;

See also: Examples for Permitted VARCHAR Declarations

 

Leaving content frame