The mi_set_connection_user_data() function

The mi_set_connection_user_data() function associates the address of user data with an open connection.

Syntax

mi_integer mi_set_connection_user_data(conn, user_data_ptr)
   MI_CONNECTION *conn;
   void *user_data_ptr;
conn
A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().

The value 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.

user_data_ptr
A pointer to user data to associate with the specified connection.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_set_connection_user_data() function assigns the user-data pointer that user_data_ptr references to the connection descriptor that conn references. The user-data pointer is the address to a user-defined buffer or structure that contains private information you want to keep with the specified connection.

The DataBlade API does not interpret or touch the associated user-data pointer, other than to store it in the connection descriptor. Cast the user_data_ptr pointer to void * before you store it as user data in a connection descriptor.

You can obtain the user-data pointer from a connection descriptor with the mi_set_connection_user_data() function.
Important: Session-duration function descriptors and named memory are advanced features of the DataBlade API. They can adversely affect your UDR if you use them incorrectly. Use them only when a regular function descriptor cannot perform the task you need done. For more information, see the HCL OneDB™ DataBlade API Programmer's Guide.

Return values

MI_OK
The function was successful.
MI_ERROR
The function was not successful.