Handling Varying String Data Types (Embedded SQL Guide)

From InterBase
Jump to: navigation, search

Go Up to Understanding the XSQLDA (Embedded SQL Guide)

VARCHAR, CHARACTER VARYING, and NCHAR VARYING data types require careful handling in DSQL. The first two bytes of these data types contain string length information, while the remainder of the data contains the actual bytes of string data to process.

To avoid having to write code to extract and process variable-length strings in an application, it is possible to force these data types to fixed length using SQL macro expressions. For more information about forcing variable-length data to fixed length for processing, see Coercing Data Types (Embedded SQL Guide).

Applications can, instead, detect and process variable-length data directly. To do so, they must extract the first two bytes from the string to determine the byte-length of the string itself, then read the string, byte-by-byte, into a null-terminated buffer.

Advance To: