The mi_get_id() function

The mi_get_id() function enables you to obtain statement identifiers or session identifiers.

Syntax

mi_integer mi_get_id(*conn, id_type)
   MI_CONNECTION *conn;
   MI_ID id_type;
conn
A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().
id_type
An integer that specifies the type of identifier to obtain. Valid values for id_type are:
MI_STATEMENT_ID
Obtains a statement identifier.
MI_SESSION_ID
Obtains a session identifier.
Valid in client LIBMI application? Valid in user-defined routine?
No Yes

Usage

The mi_get_id() function returns a statement or session identifier, depending on the value of the id_type parameter. To specify the identifier to obtain, mi_get_id() has an id_type argument of type MI_ID, which supports the cursor-action constants in the following list.
Value of id_type
Description
MI_STATEMENT_ID
The statement identifier is an integer value that identifies the prepared statement that most recently executed.

The mi_get_id() function validates the connection that conn identifies and raises an error if the connection is invalid.

MI_SESSION_ID
The session identifier is an integer value that identifies the current client session. In a client LIBMI application, the session identifier corresponds to a connection.

The mi_get_id() function does not validate the connection that conn identifies.

The mi_get_id() function is useful when you are debugging a DataBlade® API module. You can use it with the MI_STATEMENT_ID argument to determine which prepared statement last executed. When you have many sessions that write to the same trace file, you can use mi_get_id() with the MI_SESSION_ID argument to identify the session.

For more information about statement identifiers, see the Informix® DataBlade® API Programmer's Guide.

Return values

0
indicates that no statement or session identifier currently exists.
>0
A one- or two-digit number that represents the session or statement identifier.

The function raises an exception if id_type is an invalid type.