# mco_close_all_instances
RT

> Close all database instances.

### Prototype

        MCO_RET	mco_close_all_instances(	void );

### Arguments

void | No arguments

### Description

> This function destroys all database instances. It is used to cleanup possible previous database instances after an application crash.

### Return Codes

MCO_S_OK | All database instances closed successfully
MCO_ERR_DB | An internal error occurred closing one or more instances
MCO_E_OPENED_SESSIONS | There are open connections to the database. (Call `mco_db_disconnect()` for all open sessions first.)

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

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

            /* Clean up any previously opened database instances. */
            rc = mco_close_all_instances();

            if ( MCO_S_OK != rc )
            {
                rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params );

                ...
            }
        }

### Files

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