mco_trans_start_ex

Start a database transaction with an isolation level.

Prototype

    MCO_RET mco_trans_start_ex(
            /*IN*/ mco_db_h db,
            /*IN*/ MCO_TRANS_TYPE trans_type,
            /*IN*/ MCO_TRANS_PRIORITY priority,
            /*IN*/ MCO_TRANS_ISOLATION_LEVEL level,
            /*OUT*/ mco_trans_h * t
    );

Arguments

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.
level
An isolation level for the MVCC Transaction Manager, taken from the enum MCO_TRANS_ISOLATION_LEVEL.
t
The address of a mco_trans_h to receive the transaction handle.

Description

This function starts a transaction. It is an extended version of the function mco_trans_start() that allows setting the transaction isolation level only for the current transaction. This is in contrast with the method of calling mco_trans_set_default_isolation_level() that sets the isolation level for all transactions initiated from the current connection.

Return Codes

MCO_S_OK
The transaction was started successfully.
MCO_ERR_TRN
A database transaction error occurred.

Example

    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_ex( db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, MCO_SERIALIZABLE, &t );

            if ( MCO_S_OK == rc )
            {
                ...
                rc = mco_trans_commit( t );
                ...
            }
        }
        ...
    }

Files

Header file:
mco.h
Source file:
mcoabst.c
Library:
libmcolib.a