INFORMIX
DataBlade API Programmer's Manual
Chapter 2: Using DataBlade API Data Types
Home Contents Index Master Index New Book

Variable-Length Data Structures

The DataBlade API provides two variable-length structures: mi_lvarchar and mi_bitvarying. Use the mi_lvarchar structure for text data and the mi_bitvarying structure for other data. In fact, these two structures are the same underlying structure, but you might need to cast between these types to avoid warnings.

The following functions are useful for manipulating variable-length data.

Accessor Function Name Description

mi_get_varlen()

Gets the length of the data contained in the structure.

mi_get_vardata()

Gets a pointer to the data contained in the structure.

mi_get_vardata_align()

Gets a pointer to the data contained in the structure, adjusting for any initial padding required to align the data on a particular byte boundary. (See the following information about the align value.)

mi_new_var()

Creates a new variable-length structure for text data.

mi_var_copy()

Allocates and creates a copy of a variable-length structure for text data.

mi_var_free()

Deallocates a variable-length structure.

mi_set_varlen()

Sets the length of the data contained in the structure.

mi_set_vardata()

Sets the data in the structure.

mi_set_vardata_align()

Sets the data in the structure, adjusting by adding any initial padding required to align the data on a particular byte boundary.

Use the mi_get_vardata_align() and mi_set_vardata_align() functions with data types whose alignment is not 4 bytes, the default value. When you create such data types, set the align argument to the align value that is in the sysxtdtypes table.

For example, the mi_double_precision data type is aligned on an 8-byte boundary. To access the data portion of an array of mi_double_precision, use mi_get_vardata_align() with an align value of 8.

The database server returns binary results for variable-length data from the database server in variable-length format. A value is variable length if a call to mi_column_type_length() for that column returns -1.




DataBlade API Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.