mi_lvarchar *mi_get_cursor_table(cursor_name)
mi_lvarchar *cursor_name;
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.
See also the descriptions of mi_open_prepared_statement( ) and mi_prepare( ).
For information on how to pass a cursor name to a prepared statement, see the IBM Informix: DataBlade API Programmer's Guide.