The lvarchar pointer host variable

The lvarchar pointer host variable is designed for inserting or selecting user-defined or opaque types that can be represented in a character-string format.

The size of the character-string representation for opaque type columns can vary for each row so that the size of the data is unknown until the column is fetched into a host variable. The size of the data that an lvarchar pointer host variable references can range up to 2 GB.

The lvarchar pointer type is not equivalent to a C-language char pointer. maintains its own internal representation for the lvarchar pointer type. This representation is identical to the representation of a var binary host variable, except that it supports ASCII data as opposed to binary data. You must use the ifx_var() functions to manipulate an lvarchar pointer host variable. The ifx_var() functions can only be used for lvarchar variables declared as pointers and for var binary variables, but not for lvarchar variables of a fixed size. For a list of the functions that you can use with lvarchar and var binary variables, see The lvarchar pointer and var binary library functions.

Because the size of the data in opaque type columns can vary from one row in the table to another, you cannot know the maximum size of the data that the database server will return. When you use an lvarchar pointer host variable, you can either let allocate memory to hold the data, based on the size of the data coming from the database server, or you can allocate the memory yourself. Use the ifx_var_flag() function to specify which method you will use. In either case you must explicitly free the memory, by using the ifx_var_dealloc() function.