The mi_get_cursor_table() function

The mi_get_cursor_table() function obtains the name of the database table that is associated with a specified cursor.

Syntax

mi_lvarchar *mi_get_cursor_table(cursor_name)
   mi_lvarchar *cursor_name;
cursor_name
A pointer to the varying-length structure that contains the internal representation of the cursor name.
Valid in client LIBMI application? Valid in user-defined routine?
No Yes

Usage

The mi_get_cursor_table() function obtains the name of the table in the query that is associated with the cursor that cursor_name references. The function expects the cursor name to be in a varying-length (mi_lvarchar) structure. If the table is not present, mi_get_cursor_table() returns an error. Otherwise, it returns the table name associated with the cursor. If the query is performing a join (which involves two tables), mi_get_cursor_table() returns the name of the first table in the query.

When you create a generic UDR, you can use mi_get_cursor_table() to obtain the name of the table from the associated cursor, as the following code fragment shows:
MI_CONNECTION *conn;
MI_STATEMENT *stmt_desc1;
mi_lvarchar *tbl_name;

stmt_desc1 = mi_prepare(conn, "select * from systables;", 0);
if ( (mi_open_prepared_statement(stmt_desc1, 0, 0, 0, 
   0, 0, 0, 0, "curs1", 0, 0)) == MI_OK )
   tbl_name =
      mi_get_cursor_table(mi_string_to_lvarchar("curs1"));
   ...

In the preceding code fragment, tbl_name points to an mi_lvarchar structure whose data is the non-null-terminated string systables. The table name is useful to include in error messages.

For information about how to pass a cursor name to a prepared statement, see the Informix® DataBlade® API Programmer's Guide.

Return values

An mi_lvarchar pointer
A pointer to a varying-length structure that contains the name of the table associated with the specified cursor.
NULL
The function was not successful.