Compare the value(s) referenced by the current position of the cursor with specified value(s).
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 );
| t | The transaction handle |
|
cursor |
Address of a |
|
keys |
An array of |
|
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 |
Compare the value(s) referenced by the current position of the index cursor with value(s) in parameter
keys.
| MCO_S_OK | The compare operation was successfully performed |
|
Keys_count mismatch |
|
|
MCO_E_UDA_WRONG_KEY_TYPE |
Key type mismatch |
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;
...
}
}
...
}