mco_get_last_autoid

Return the last generated value for an object of any database class that has an autoid field defined.

Prototype

    MCO_RET mco_get_last_autoid(/*IN*/ mco_db_h db,
                     /*OUT*/ uint8 *id);

Arguments

db
The database handle.
id
Address of an unsigned 8-byte integer to receive the last autoid value inserted for this database connection.

Description

This function returns the last generated value for an object of any database class that has an autoid field defined. Autoids are unique generated values within a database.

Return Codes

MCO_S_OK
The current last autoid value was successfully returned.

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;
        uint8 id;
        ...

        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);
            ...
            rc = mco_get_last_autoid(db, &id);
        }
    }

Files

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