Start a database transaction.
MCO_RET mco_trans_start( /*IN*/ mco_db_h db,
/*IN*/ MCO_TRANS_TYPE trans_type,
/*IN*/ MCO_TRANS_PRIORITY priority,
/*OUT*/ mco_trans_h * t );
| db | The database handle for a database connection |
| trans_type | A one-byte unsigned value, taken from the enum MCO_TRANS_TYPE |
| priority | A two-byte unsigned value, taken from the enum MCO_TRANS_PRIORITY |
| t | The address of a mco_trans_h to receive the transaction handle |
This function initiates a transaction for the database referenced by db. All database access must occur within the scope of a transaction. This function is called with the
MCO_READ_ONLYtransaction type for database navigation. If the intent is to find a database object for modification (Update of Delete) theMCO_UPDATEtransaction type should be specified. To update a database object aMCO_READ_WRITEtransaction must be started, or the current transaction must be upgraded by calling functionmco_trans_upgrade().
| MCO_S_OK | The database was created successfully |
| MCO_ERR_TRN | A database transaction error occurred |
Application snippet:
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_WRITE, MCO_TRANS_FOREGROUND, &t);
if ( MCO_S_OK == rc )
{
...
rc = mco_trans_commit( t );
...
}
}
...
}