# mco_trans_upgrade
RT

> Upgrade to a `READ_WRITE` transaction.

### Prototype

        MCO_RET	mco_trans_upgrade(	/*INOUT*/ mco_trans_h t );

### Arguments

t | The `mco_trans_h` transaction handle to upgrade

### Description

> This function upgrades a `MCO_READ_ONLY` or `MCO_UPDATE` transaction to `MCO_READ_WRITE`.

### Return Codes

MCO_S_OK | The transaction was upgraded successfully
MCO_E_UPGRADE_FAILED | The transaction could not be upgraded. Another read thread has upgraded. Try again
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(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
                if ( MCO_S_OK == rc )
                {
                    ...
                    rc = mco_trans_upgrade( t );

                    ...
                    rc = mco_trans_commit( t );
                    ...
                }
            }
            ...
        }

### Files

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