Assign a callback function to be invoked when a transaction is committed or rolled back.
void mco_set_trans_callback(
/*IN*/ mco_db_h db,
/*IN*/ mco_trans_callback_t callback,
/*IN*/ void* arg);
db
mco_db_connect().callback
mco_trans_callback()
function that is called when a transaction is committed or rolled back.arg
This function assigns a callback to be invoked when a transaction is committed or rolled back. The callback function is called with the transaction handle, the transaction state, and a user-supplied argument.
Callback Prototype
... static MCO_RET mco_trans_callback( mco_trans_h trans, mco_trans_state state, void* arg ) { if (state == MCO_TRANS_POSTCOMMIT) { ((McoAsyncCommitSession*)arg)->commit(); } return MCO_S_OK; } ...Callback Parameters
transHandle of the transaction being processed.stateIndicates the current transaction state. One of the following values:
MCO_TRANS_PRECOMMIT— the transaction is about to be committed.MCO_TRANS_POSTCOMMIT— the transaction has been committed.MCO_TRANS_ROLLBACK— the transaction has been rolled back.argUser-defined pointer passed to the callback.Callback Return Value
The callback function should return
MCO_S_OKon success.
...
void McoAsyncCommitSession::listen(McoSqlSession* session)
{
mco_db_h dbh = session->getHandle();
mco_set_trans_callback(dbh, mco_trans_callback, this);
}
...