DeleteObject read in an object an marks it for deletion, the object remains within the database until CommitTransaction is called, this operation can be undone by calling RestoreObjectbefore commiting the transaction if an incorrect object is found.
unsigned int DeleteObject (
   unsigned int tableID,
   __int64 objectID = 0,
   CODBPP::Object *object = NULL
unsigned int DeleteObject (
   unsigned int tableID,
   CODBPP::Mode operation,
   CODBPP::Object *object = NULL,
   unsigned int index = 0,
   const void *key = NULL,
   unsigned int *matchingRow = NULL


tableIDthe table ID defining the table's handle.
objectIDthe object ID defining the object's handle when using the shorthand version.
operationvalid operations only.
objectfor the returned object addresses.
indexthe index value, 0 for object ID hash index, 1 for the first defined index.
keythe key value used in any find comparison.
matchingRowused to identify which row of a sub-table field, within the current object has the matching multi-entry index value.

Return Values

If the method succeeds, the return value is zero else see error codes for more details.


  • Once DeleteObject has deleted an object, all the index values held by that object can be reused by any other object during the transaction, except for the objectID which is not reusable.
  • If the objectID is zero (0), then DeleteObject will try and delete the last object successfully read by ReadObject.
  • DeleteObject will not delete an added object, use RestoreObject RestoreObject to delete and added object.
  • DeleteObject will attempt to lock twenty times longer if the object is above the transaction’s high water mark, if the object is below the mark than DeleteObject will return an error if unable to gain object lock.
  • DeleteObject will allow the operation of NO_WAIT and SHORT_WAIT if the object is known to be locked and there is little need to wait the entire timeout period before returning CODBPP::UNABLE_TO_LOCK_OBJECT.
Example Use
char16_t *message;
CODBPP::Object object;
struct FixedObject{
   int First;
   double Second;
} *fixedObject;
char16_t *userName = TEXT("UserName");
unsigned int error;
if((error = database.BeginTransaction()) == NO_ERROR){
   if((error = database.OpenTable(1)) == NO_ERROR){
      if((error = database.DeleteObject(1,CODBPP::EQUALTO,&object,1,userName)) == NO_ERROR){
         fixedObject = (struct FixedObject*)object.fixed;
         if(fixedObject->First == 123 && fixedObject->Second == 0)
            error = database.CommitTransaction();
         else error = database.AbortTransaction();
         if(error == (0x10000 | CODBPP::NOT_FOUND_INDEX_KEY)){
            MessageBox(TEXT("Object not found"));
            error = NO_ERROR;
if(error && database.GetErrorMessage(&message) == NO_ERROR)

Also See

AddObject, NewObject, ReadObject, RewriteObject, RestoreObject
Comments (0)Listen All
Characters left: 2500
Ekky Software Homepage Ekky Software Homepage ObjectDatabase++ TScript Ekky Software Homepage Ekky Software Homepage ObjectDatabase++ TScript