# mco_copy_handle
RT

> Copy an object handle.

### Prototype

        MCO_RET mco_copy_handle( /*IN*/ mco_db_h db,
                      /*OUT*/ MCO_Hf * dst,
                      /*IN*/ MCO_Hf * src );

### Arguments

db | The database handle
dst | The address of an object handle to receive the copy
src | The address of the object handle to copy

### Description

> Because object handles cannot be copied as a raw sequence of bytes (using `memcpy()` for example), this function is provided for rare occasions when it might be useful to copy an object handle.

### Return Codes

MCO_S_OK | The object handle was successfully copied

### 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;
            ...

            if( (rc = mco_runtime_start()) != MCO_S_OK)
                exit(-1);

            rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params );
            if ( MCO_S_OK != rc )
            {
                rc = mco_db_connect(  dbname, &db );
                ...
                // Instantiate an object of class A and get its class code
                rc = mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
                if ( MCO_S_OK == rc ) {
                    A        a;   /* Object handle */
                    uint2 code;
                    rc = A_new ( t, &a );
                    rc = mco_trans_commit( t );

                    A a2;

                    rc = mco_copy_handle( db, &a2, &a );

                }
            }
        }

### Files

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