informix
Informix DataBlade API Programmer's Manual
DataBlade API Function Descriptions

mi_cast_get()

The mi_cast_get() function looks up a registered function by the type identifiers of its source and target data types and returns its function descriptor.

Syntax

Usage

The mi_cast_get() function whose source and target data types the source_type and target_type arguments references. It accepts source and target data types as pointers to type identifiers. This function is one of the functions of the Fastpath interface. It is a constructor function for the function descriptor.

The mi_cast_get() function performs the following tasks:

  1. Looks in the syscasts system catalog table for the cast function that casts from the source_type data type to the target_type data type.
  2. Allocates a function descriptor for the cast function and saves the routine sequence in this descriptor.
  3. Allocates an MI_FPARAM structure for the cast function and saves the argument and return-value information in this structure.
  4. Sets the cast_status output parameter to provide status information about the cast function.
  5. Returns a pointer to the function descriptor that it allocates for the cast function.

The mi_cast_get() function allocates a new function descriptor in the PER_COMMAND memory duration.

The cast_status flag can have one of the following constant values.

Cast-Type Constant Purpose
MI_ERROR_CAST The mi_cast_get() function failed.
MI_NO_CAST function exists between the two specified types. The user must write a function to perform the cast.
MI_NOP_CAST function is needed between the two types. The user can cast directly without a function.
MI_SYSTEM_CAST A built-in cast exists to cast between two data types, usually built-in data types.
MI_EXPLICIT_CAST A user-defined cast function exists to cast between the two types. The cast is explicit.
MI_IMPLICIT_CAST A user-defined cast function exists to cast between the two types. The cast is implicit.

The following call to mi_cast_get() looks for a cast function that converts from an INTEGER to an opaque data type called percent:

Return Values

MI_FUNC_DESC * is a pointer to the function descriptor of the cast function that casts from source_type to target_type.
NULL indicates that the cast_status value is one of the following constants:
MI_ERROR_CAST The function was not successful.
MI_NO_CAST No matching cast function exists.
MI_NOP_CAST No cast function is needed between the source and target data types.

Related Topics

See the descriptions of the following functions: mi_fparam_get(), mi_routine_get(), mi_routine_exec(), mi_routine_end(), and mi_td_cast_get().

For more information on the use of the Fastpath interface, see Calling UDRs with the Fastpath Interface.


Informix DataBlade API Programmer's Manual, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved