classname_from_cursor

This function returns a handle to the object at the current cursor position.

Prototype

 
    MCO_RET	classname_from_cursor(	/*IN*/ mco_trans_h trans, 
                       /*IN*/ mco_cursor_h cursor
                       /*OUT*/ classname * handle );
 

Arguments

trans A MCO_READ_WRITE transaction handle established by mco_trans_start()

cursor

An instance of a mco_cursor_h that has been positioned to an object via the tree index _search function or one of the cursor navigation functions

handle The address of a variable of type class handle

Description

This function obtains a reference to an object located by a cursor.

Return Codes

MCO_S_OK The object was referenced successfully
MCO_E_CURSOR_INVALID Invalid cursor

MCO_ERR_CURSOR

 

Example

 
 
    Application snippet:
        
     
    const char * db_name = "treedb";

 
    int main(int argc, char* argv[])
    {
        MCO_RET rc = MCO_S_OK;
        mco_db_h db = 0;
        sample_memory_t dbmem;
        mco_trans_h t;
        mco_cursor_t csr;
        int i;
         
        Record rec;
        uint4 key;
        char name[64];
        uint2 size;
        int nRecs = 1001;
        char str[64];
         
        sample_os_initialize(DEFAULT);
        sample_header( sample_descr );
        /* Set fatal error handler and start eXtremeDB runtime */
        mco_error_set_handler( &sample_errhandler );
        mco_runtime_start();
         
        /* Open and connect to database */
        rc = sample_open_database( db_name, treedb_get_dictionary(), DATABASE_SIZE, CACHE_SIZE,
        MEMORY_PAGE_SIZE, PSTORAGE_PAGE_SIZE, 5, &dbmem );
         
        ...
         
        /* Fill database */
        printf( "\n\tInsert 1000 test records " );
        for ( i = 0; i < 1000 && MCO_S_OK == rc; i++ )
         {
            rc = mco_trans_start( db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t );
         
            ...
         
            /* Get Record from cursor */
            rc = Record_from_cursor( t, &csr, &rec );
        
         
            ...
         
        }
    }
     

Related Topics Link IconRelated Topics