2. Embedded QUEL for C : C Variables and Data Types : Variable Usage : Using a Varying Length String Variable (Varchar)
 
Share this page                  
Using a Varying Length String Variable (Varchar)
The syntax for referring to a varchar variable is the same as referring to a simple variable:
varchar_name
Syntax Notes:
When using a variable declared with the varchar storage class, you cannot reference the two members of the structure individually but only the structure as a whole. This rule differs from the rule that applies to regular structure member referencing. For example, the following declaration and retrieve statement are legal:
## varchar struct {
##       short        buf_size;
##       char        buf[100];
## } vch;

## retrieve (vch = objects.data)
But the following statement will generate an error on the use of the member "buf_size":
## retrieve (vch = objects.data
##       vch.buf_size = length(objects.data))
When you use the variable to retrieve Ingres data, the 2-byte length field is assigned the length of the data and the data is copied into the fixed length character array. The data is not null-terminated. You can use a varchar variable to retrieve data in the retrieve, retrieve cursor, inquire_ingres, getform, finalize, unloadtable, getrow, and inquire_frs statements.
When you use the variable to set Ingres data, the program must assign the length of the data (in the character array) to the 2-byte length field. You can use a varchar variable to set data in the append, replace, replace cursor, putform, initialize, loadtable, putrow, insertrow, and set_frs statements.