DeleteObject

ODBPPLib.IODBPP.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 RestoreObject before commiting the transaction if an incorrect object is found.
DatabaseObject DeleteObject (
   uint tableId,
   uint mode,
   uint index,
   object key,
);

Parameters

tableIdthe table ID defining the table's handle
modevalid mode operations only.
indexthe index value, 0 for object ID hash index, 1 for the first defined index.
keythe key value used in any find comparison.

Return Values

DeleteObject returns the DatabaseObject with the newly deleted object's values.

Remarks

  • DeleteObject will return null if there was no matching object.
  • 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 ODBPP.NO_WAIT and ODBPP.SHORT_WAIT if the object is known to be locked and there is little need to wait the entire timeout period before returning.
Example Use
  • C#
public static uint FIRST_TABLE = 1;
private void button1_Click(object sender, EventArgs e)
   try{
      ODBPPLib.ODBPP odbpp = new ODBPPLib.ODBPP();
      odbpp.OpenDatabase("C:\\My\\Database\\Control\\File.odc");
      odbpp.BeginTransaction(odbpp.SHARED, 60000);
      odbpp.OpenTable(FIRST_TABLE);
      object[] key = new object[2];
      key[0] = "127";
      key[1] = 0;
      result = odbpp.DeleteObject(FIRST_TABLE, odbpp.GREATER_EQUALTO, 6, key);
      if(result != null && result.readField("First") == 123)
      {
         odbpp.CommitTransaction(true);
      }
   }
   catch (Exception e1)
   {
      MessageBox.Show(e1.Message);
   }
}

Also See

AddObject, GetObject, NewObject, ReadObject, RewriteObject, RestoreObject
Listen All
Comments (0)
Characters left: 2500
 
Ekky Software Homepage T-Accounts Online ObjectDatabase++ TScript Ekky Software Homepage T-Accounts Onlinee ObjectDatabase++ TScript