classname_delete_all

This function deletes all database objects of this class.

Prototype

 
    MCO_RET	classname_delete_all(	/*IN*/ mco_trans_h t );
 

Arguments

t A MCO_READ_WRITE transaction handle returned by mco_trans_start()

Description

This function will remove all objects (and their index entries) of a given class.

Return Codes

MCO_S_OK The objects were deleted successfully
MCO_E_ACCESS The transaction handle is MCO_READ_ONLY

MCO_E_DELETED

This object has been deleted

MCO_E_NOMEM

Database memory allocation error

MCO_ERR_TRN

Error in the enclosing transaction

Example

The following code snippets demonstrate how classname_delete_all() is used to delete all database objects of a specific class.

 
    Snippet from schema file:
        
 
    class Record
    {
        uint4 key;
         
        hash <key> hkey;
    };
     
    Application snippet:
        
     
    int delete_records(mco_db_h db)
    {
        MCO_RET rc;
        mco_trans_h t;
         
        rc = mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
        if ( MCO_S_OK == rc ) 
        {
            rc = Record_delete_all(t);
            if ( MCO_S_OK == rc )
             {
                rc = mco_trans_commit(t);
            }
            else
            {
                printf("\n\t error(%d) from delete_all", rc);
                rc = mco_trans_rollback(t);
            }
        }
        ...
    }
     
 

Related Topics Link IconRelated Topics