Check the internal structure of the cursor.
MCO_RET mco_cursor_check( /*IN*/ mco_trans_h t, /*IN*/ mco_cursor_h c);
t |
The |
c |
A cursor handle returned from a cursor or index search function |
This function checks the internal structure of the cursor. It returns
MCO_S_OK
if the cursor’s internal structure is valid and the index that the cursor is built for has not been changed. Cursors are valid across transactions, so applications may need to know if the current cursor is valid when it is reused in a transaction different from the one that created it.Note that it is normal for an application to call
mco_w_obj_from_cursor()
many times, so the effect of this check can have a significant impact on performance. For this reason the part of this function that checks the validity of the object handle is present only in the debug version of the runtime libraries – it is removed from the release version of the libraries. As a result, where in some casesmco_w_obj_from_cursor()
might returnMCO_E_CURSOR_INVALID
when using the debug libraries, the same function call when using the release version of the libraries can returnMCO_S_OK
. So developers should take care to handle all return codes from cursor functions and eliminate anyMCO_E_CURSOR_INVALID
situations during development with the debug libraries.
MCO_S_OK | The cursor is valid |
MCO_E_INVALID_HANDLE | Cursor not opened |
MCO_E_CURSOR_INVALID |
Cursor not positioned to an object |
MCO_E_CURSOR_CLOSED |
Cursor has been closed |
Application snippet: const char * dbname = "SimpleDb"; int main(int argc, char* argv[]) { mco_db_h db; MCO_RET rc; mco_device_t dev; mco_db_params_t db_params; mco_trans_h t; mco_cursor_t c; MCO_CURSOR_TYPE ctype; ... rc = mco_db_open_dev( dbname, simple_get_dictionary(), &dev, 1, &db_params ); if ( MCO_S_OK != rc ) { rc = mco_db_connect( dbname, &db ); ... rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t); if ( MCO_S_OK == rc ) { ... A_list_cursor( t, &c); ... rc = mco_cursor_check( t, &c ); ... } ... }