ReadObject

ReadObject finds an object matching the search values, reads the object into the table's buffers and locks the object, this operation does not log or back-up the object.
unsigned __int64 ReadObject (
   unsigned int tableID,
   __int64 objectID,
   CODBPP::Object *object = NULL
);
unsigned __int64 ReadObject (
   unsigned int tableID,
   __int64 objectID,
   CODBPP::Mode operation,
   CODBPP::Object *object = NULL
);
unsigned __int64 ReadObject (
   unsigned int tableID,
   CODBPP::Mode operation,
   CODBPP::Object *object = NULL,
   unsigned int index = 0,
   const void *key = NULL,
   unsigned int *matchingRow = NULL
);

Parameters

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.

Remarks

  • ReadObject can be used before DeleteObject or RewriteObject to enable 2-phased commit protocols.
  • ReadObject 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 ReadObject will return an error if unable to gain object lock.
  • ReadObject will allow the operation of CODBPP::NO_LOCK if the object is un-important to the finial results of the transaction and locking would only block other transactions from completing.
  • ReadObject will allow the operation of CODBPP::NO_WAIT and CODBPP::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
  • C++
#include "ODBPP.h"

#define FIRST_TABLE 1

struct FixedObject{
   int First;
   double Second;
} *fixedObject;

int wmain(int argc, wchar_t* argv[])
{
   unsigned __int64 error;
   CODBPP database;
   CODBPP::Object object;
   const char16_t *userName = u"UserName", *message;
   char16_t buffer[128];
   if((error = database.BeginTransaction()) == NO_ERROR
   && (error = database.OpenTable(FIRST_TABLE)) == NO_ERROR
   && (error = database.ReadObject(FIRST_TABLE,
      CODBPP::EQUALTO,&object,1,userName)) == NO_ERROR){
      fixedObject = (struct FixedObject*)object.fixed;
      swprintf(buffer,u"First = %d, Second = %g",
                 fixedObject->First, fixedObject->Second);
      MessageBox(buffer);
   }
   if(error && database.GetErrorMessage(&message) == NO_ERROR)
      MessageBox(message);
   database.EndTransaction();
   return NO_ERROR;
}

Also See

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