classname_new

This function creates a new instance of a database object (without an OID).

Prototype

 
    MCO_RET	classname_new(	/*IN*/ mco_trans_h t, 
                  /*OUT*/ classname * handle );
 

Arguments

t A MCO_READ_WRITE transaction handle returned by mco_trans_start()
handle The address of a variable of type class handle

Description

This function will reserve space for a new instance of the class and return a reference to the instance for classes declared without an OID.

Return Codes

MCO_S_OK The instance was reserved successfully
MCO_E_ACCESS The transaction handle is MCO_READ_ONLY
MCO_E_TRANSACT A transaction error occurred
MCO_E_NOMEM

Database memory allocation error

Example

 
    Application snippet:
        
     
    const char * dbname = "SimpleDb";
     
    int main(int argc, char* argv[])
    {
        mco_db_h db;
        MCO_RET rc;
        mco_trans_t       t;
        ...
         
        mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
        if ( MCO_S_OK != rc )
        {
            A a;
            rc = A_new( t, &a );
        
            ...
        }
    }
 

Related Topics Link IconRelated Topics