MI_FUNC_DESC *mi_cast_get(conn, source_type, target_type, cast_status) MI_CONNECTION *conn; MI_TYPEID *source_type; MI_TYPEID *target_type; mi_char *cast_status;
can be a pointer to a session-duration connection descriptor established by a previous call to mi_get_session_connection( ). Use of a session-duration connection descriptor is an advanced feature of the DataBlade API.
Valid in Client LIBMI Application? | Valid in User-Defined Routine? |
---|---|
Yes | Yes |
The mi_cast_get( ) function obtains a function descriptor for a cast function whose source and target data types the source_type and target_type arguments reference. The mi_cast_get( ) function 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.
To obtain a function descriptor for a cast function, the mi_cast_get( ) function performs the following tasks:
When you pass a public connection descriptor (from mi_open( )), the mi_cast_get( ) function allocates the new function descriptor in the PER_COMMAND memory duration. If you pass a session-duration connection descriptor (from mi_get_session_connection( )), mi_cast_get( ) allocates the new function descriptor in the PER_SESSION memory duration. This function descriptor is called a session-duration function descriptor. For more information, see the IBM Informix: DataBlade API Programmer's Guide.
The cast_status flag can have one of the following constant values.
The following call to mi_cast_get( ) looks for a cast function that converts from the INTEGER data type to an opaque data type named percent:
MI_TYPEID *src_type, *trgt_type; mi_char cast_stat; MI_FUNC_DESC *func_desc; MI_CONNECTION *conn; ... src_type = mi_typestring_to_id(conn, "INTEGER"); trgt_type = mi_typestring_to_id(conn, "percent"); func_desc = mi_cast_get(conn, &src_type, &trgt_type, &cast_stat); if ( func_desc == NULL ) { switch ( cast_stat ) { case MI_NO_CAST: mi_db_error_raise(NULL, MI_EXCEPTION, "No cast function found."); break; case MI_ERROR_CAST: mi_db_error_raise(NULL, MI_EXCEPTION, "Error in mi_cast_get( ) function."); break; case MI_NOP_CAST: mi_db_error_raise(NULL, MI_EXCEPTION, "No cast function needed."); break; ...
See also the descriptions of mi_fparam_get( ), mi_get_session_connection( ), mi_open( ), mi_routine_end( ), mi_routine_exec( ), mi_routine_get( ), mi_server_connect( ), mi_server_reconnect( ), and mi_td_cast_get( ).