mco_uda_compare

Compare the value(s) referenced by the current position of the cursor with specified value(s).

Prototype

 
    MCO_RET mco_uda_compare(	/*IN*/ mco_trans_h t,
                  /*IN*/ const mco_cursor_t * cursor,  
                  /*IN*/ const mco_uda_value_t * keys,
                  /*IN*/ unsigned short keys_count,
                  /*OUT*/ int * cmp_result );
 

Arguments

t The transaction handle

cursor

Address of a mco_cursor_t struct containing the initialized cursor

keys

An array of mco_uda_value_t structs containing the key values to be compared

keys_count

The size of keys array

cmp_result

Compare result: Zero if key values are equal to those in the current cursor position, less than or greater than zero id keys don't match

Description

Compare the value(s) referenced by the current position of the index cursor with value(s) in parameter keys.

Return Codes

MCO_S_OK The compare operation was successfully performed

MCO_E_UDA_WRONG_KEY_NUM

Keys_count mismatch

MCO_E_UDA_WRONG_KEY_TYPE

Key type mismatch

Example

 
    Application snippet:
        
     
    int main(int argc, char* argv[])
    {
        MCO_RET rc;
        mco_db_h db;
        mco_trans_h t;
        mco_cursor_t csr;
        mco_uda_value_t keys[1];
        unsigned short struct_no = 1;
        unsigned short index_no = 2;
        int cmp_result;
        ...
 
        rc = mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
        if ( MCO_S_OK == rc)
        {
            ...
            keys[0].type = MCO_DD_UINT4;
            keys[0].u4   = 120;
            /* Lookup the first object with id >= 120. */
            rc = mco_uda_lookup(t, struct_no, index_no, MCO_GE, 
                        keys, 1, &csr); 
            for ( ; rc == MCO_S_OK; rc = mco_cursor_next(t, &csr)) {
            {
                rc = mco_uda_compare(t, &csr, keys, 1, &cmp_result);
        
                /* Break out of loop when key value is no longer 120 */
                if ( 0 != cmp_result ) break;
                ...
            }
        }
        ...
    }
 

Files

Header file:
mcouda.h
Source file:
mcouda.c
Library:
libmcouda.a