Home | Previous Page | Next Page   DataBlade API Overview > Accessing SQL Data Types > Character Data Types >

Character Processing

The DataBlade API library provides the following functions to process character data:

Global Language Support

You can use these character-processing functions on NCHAR and NVARCHAR data. You can also use the character processing that the IBM Informix GLS interface provides to handle multibyte characters.

End of Global Language Support

Transferring Character Data (Server)

To transfer character data between different computer architectures, the DataBlade API provides the following functions that handle type alignment.

DataBlade API Function Description
mi_get_string( ) Copies a character string, converting any difference in alignment on the client computer to that of the server computer
mi_put_string( ) Copies a character string, converting any difference in alignment on the server computer to that of the client computer

The mi_get_string( ) and mi_put_string( ) functions are useful in the send and receive support function of an opaque data type that contains character data (such as mi_string or mi_char). They ensure that character data remains aligned when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data with Computer-Specific Data Types.

Converting Character Data

Both the DataBlade API library and the ESQL/C library provide functions that convert between the binary and text representation of values.

DataBlade API Functions for String Conversion

Many DataBlade API functions expect to manipulate character data as an mi_lvarchar value. In addition, all SQL character data types are passed into a C UDR as an mi_lvarchar value. The DataBlade API provides the following functions to allow for conversion between a text (null-terminated string) representation of character data and its binary (internal) equivalent. The binary representation of character data is a varying-length structure (mi_lvarchar) equivalent.

DataBlade API Function Description
mi_lvarchar_to_string( ) Creates a null-terminated string from the data in a varying-length structure
mi_string_to_lvarchar( ) Creates a varying-length structure to hold a string

The mi_lvarchar_to_string( ) and mi_string_to_lvarchar( ) functions are useful for converting between null-terminated strings and varying-length structures (whose data is not null-terminated).

Server Only

The mi_lvarchar_to_string( ) and mi_string_to_lvarchar( ) functions are also useful in the input and output support functions of an opaque data type that contains mi_lvarchar values. They allow you to convert a string between its external format (text) and its internal format (mi_lvarchar) when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data Between Text and Binary Representations.

End of Server Only

For more information on the structure of an mi_lvarchar value, see Varying-Length Data Type Structures.

In addition, the DataBlade API library provides the following functions to convert text representation of values to their binary representations.

Type of String More Information
Decimal strings DataBlade API Functions for Decimal Conversion
Date strings DataBlade API Functions for Date Conversion
Date and time strings, Interval strings DataBlade API Functions for Date-Time or Interval Conversion
ESQL/C Functions for String Conversion

The ESQL/C function library provides the following functions that facilitate conversion of values in character data types (such as mi_string or mi_char) to and from some C-language data types.

Function Name Description
rstod( ) Converts a string to a double type
rstoi( ) Converts a null-terminated string to a two-byte integer (int2)
rstol( ) Converts a string to a four-byte integer (int4)

In addition, the ESQL/C library provides the following functions to convert text representation of values to their binary representation.

Type of String More Information
INT8 strings Converting INT8 Values
Decimal strings ESQL/C Functions for Decimal Conversion
Date strings ESQL/C Functions for Date Conversion
Date and time strings ESQL/C Functions for Date, Time, and Interval Conversion

Operations on Character Values

The ESQL/C function library provides the following functions to perform operations on null-terminated strings.

Function
Name
Description
ldchar( ) Copies a fixed-length string to a null-terminated string
rdownshift( ) Converts all letters to lowercase
rupshift( ) Converts all letters to uppercase
stcat( ) Concatenates one null-terminated string to another
stchar( ) Copies a null-terminated string to a fixed-length string
stcmpr( ) Compares two null-terminated strings
stcopy( ) Copies one null-terminated string to another string
stleng( ) Counts the number of bytes in a null-terminated string

Character Type Information

The DataBlade API provides functions to obtain the following information about a character (CHAR and VARCHAR) data type:

The DataBlade API provides the following functions to obtain the type and precision of a character data type.

Source DataBlade API Functions
Type Name, Type Identifier,
or Type Descriptor
Precision
For a basic data type mi_type_typedesc( ),
mi_type_typename( )
mi_type_precision( )
For a UDR argument mi_fp_argtype( ),
mi_fp_setargtype( )
mi_fp_argprec( ),
mi_fp_setargprec( )
For a UDR return value mi_fp_rettype( ),
mi_fp_setrettype( )
mi_fp_retprec( ),
mi_fp_setretprec( )
For a column mi_column_type_id( ),
mi_column_typedesc( )
mi_column_precision( )
For an input parameter in a prepared statement mi_parameter_type_id( ),
mi_parameter_type_name( )
mi_parameter_precision( )
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]