Return the last return code from an eXtremeDB function that caused a transaction to enter an error state.
MCO_RET mco_get_last_error( /*IN*/ mco_trans_h t );
t
mco_trans_h transaction handle returned by mco_trans_start().This function returns the value of the last return code from an eXtremeDB function that caused a transaction to enter an error state. After a transaction enters an error state, subsequent operations within that transaction will return
MCO_E_TRANSACTso that a call tomco_get_last_error()will return the error code of the operation that initially caused the error condition.In eXtremeDB/rt returns the current transaction error code. Applications can use the function to verify the deadline status while carrying out non-database activity within the database transaction. Specifically the
mco_get_last_error()function internally verifies the deadline at its cancellation point.
MCO_RET valueMCO_S_OK.
/* eXtremeDB */
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;
...
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 )
{
...
// Perform database operations within the transaction
...
rc = mco_get_last_error( t );
if ( MCO_S_OK != rc )
{
mco_trans_rollback(t);
}
...
}
}
...
}
/* eXtremeDB/rt */
mco_trans_h t;
mco_trans_rt_start(..., &t);
...
while (condition) {
/* ... non-DB activity ... */
if (mco_get_last_error(t) != MCO_S_OK) {
/* E_INTERRUPTED is detected */
break;
}
}
...
mco_trans_commit(t);