Perform a database lookup.
MCO_RET mco_uda_lookup( /*IN*/ mco_trans_h t,
/*IN*/ unsigned short struct_no,
/*IN*/ unsigned short index_no,
/*IN*/ MCO_OPCODE op,
/*IN*/ const mco_uda_value_t * keys,
/*IN*/ unsigned short keys_count,
/*OUT*/ mco_cursor_t * cursor );
t
struct_no
mco_dict_struct_count() - 1).index_no
struct_info.index_count - 1).op
keys
keys_count
cursor
Perform a database lookup. The function positions the cursor at the first object that satisfies the search criteria. The object handle can then be received using the
mco_uda_from_cursor()API.
MCO_S_OK
struct_no.MCO_E_UDA_STRUCT_NOT_CLASS
struct_no (not a class).MCO_E_UDA_INDEX_NOTFOUND
index_no.MCO_E_UDA_WRONG_KEY_NUM
keys_count and actual number of keys defined in the index.MCO_E_UDA_WRONG_KEY_TYPE
MCO_E_UDA_WRONG_OPCODE
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;
mco_uda_object_handle_t uda_obj;
...
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, Record_struct_no, index_no, MCO_GE,
keys, 1, &csr);
if ( MCO_S_OK == rc)
{
mco_uda_from_cursor(t, &csr, &uda_obj); /* get the handle */
...
}
}
...
}