Declare lvarchar host variables

Use the lvarchar data type to declare a host variable for the external format of an opaque data type.

The following diagram illustrates the syntax to declare an lvarchar host variable. To declare, use the lvarchar keyword as the variable data type, as the following syntax shows.

1 (1)  lvarchar?  ’ opaque type ’
1+ ,
1  variable name [ variable size ]
1  * variable
name
2  ;
Notes:
  • 1 Informix® extension
Element Purpose Restrictions SQL syntax
opaque type Name of the opaque data type whose external format is to be stored in the lvarchar variable Must already be defined in the database Identifier segment in the Informix Guide to SQL: Syntax
variable name Name of the Informix ESQL/C variable to declare as an lvarchar variable Name must conform to language-specific rules for variable names.
*variable name Name of an lvarchar pointer variable for data of unspecified length Not equivalent to a C char pointer (char *). Points to an internal ESQL/C representation for this type. You must use the ifx_var() functions to manipulate data. For more information, see The lvarchar pointer and var binary library functions. Name must conform to language-specific rules for variable names.
variable size Number of bytes to allocate for the lvarchar variable Integer value can be 1 - 32,000 bytes (32 KB).
Tip: To declare an lvarchar host variable for an LVARCHAR column, use the syntax that The lvarchar data type shows.
The following figure shows declarations for four lvarchar variables that hold the external formats of opaque-type columns.
Figure 1: Sample lvarchar host variables for opaque data type
#define CIRCLESZ 20

EXEC SQL BEGIN DECLARE SECTION;
   lvarchar 'shape' a_polygon[100];
   lvarchar 'circle' circle1[CIRCLESZ],
                  circle2[CIRCLESZ];
   lvarchar 'circle' *a_crcl_ptr;
EXEC SQL END DECLARE SECTION;

You can declare several lvarchar variables in a single declaration line. However, all variables must have the same opaque type, as the declarations for circle1 and circle2 in Sample lvarchar host variables for opaque data type show. Sample lvarchar host variables for opaque data type also shows the declaration of an lvarchar pointer for the a_crcl_ptr host variable.