# mco_db_register_udf
RT

> Register a user-defined function.

### Prototype

        MCO_RET	mco_db_register_udf(	/*IN*/ const char * dbname,
                        /*IN*/ mco_userdef_funcs_h udfs );

### Arguments

dbname | The name of the database to open. Taken from the `declare database dbname` DDL statement. Note that the maximum database name length is 16 characters
udfs | An array of user-defined functions. Normally this is obtained by calling the generated function `dbname_get_udfs()`

### Description

> This function registers the array of user-defined functions with the runtime.

### Return Codes

MCO_S_OK | The database was created successfully
MCO_E_INSTANCES_LIMIT | No more space in registry

### Example

        Application snippet:

        const char * dbname = "SimpleDb";

        int main(int argc, char* argv[])
        {
            mco_db_h db;
            MCO_RET rc;
            char *mem = malloc( DBSIZE );

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

            rc = mco_db_open( dbname, simpledb_get_dictionary(), mem, DBSIZE, (uint2)PAGESIZE );

            if( (MCO_S_OK == rc)
            {
                /* register custom compare & hash functions on database name */
                mco_db_register_udf(dbname, simpledb_get_udfs());

                /* connect to database */
                rc = mco_db_connect(dbName, &db);
                ...
            }
            ...
        }

### Files

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