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 int ReadObject (
unsigned int tableID,
__int64 objectID,
CODBPP::Object *object = NULL
);
unsigned int ReadObject (
unsigned int tableID,
__int64 objectID,
CODBPP::Mode operation,
CODBPP::Object *object = NULL
);
unsigned int ReadObject (
unsigned int tableID,
CODBPP::Mode operation,
CODBPP::Object *object = NULL,
unsigned int index = 0,
const void *key = NULL,
unsigned int *matchingRow = NULL
);
Parameters
| tableID |
The table ID defining the table's handle. |
| objectID |
The object ID defining the object's handle when using the shorthand version. |
| operation |
Valid operations only. |
| object |
For the returned object addresses. |
| index |
The index value, 0 for object ID hash index, 1 for the first defined index. |
| key |
The key value used in any find comparison. |
| matchingRow |
Used 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 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 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
CODBPP::Object object;
struct FixedObject{
int First;
double Second;
} *fixedObject;
char16_t *userName = _T"UserName", message, buffer[128];
if((error = database.BeginTransaction()) == NO_ERROR){
if((error = database.OpenTable(1)) == NO_ERROR){
if((error = database.ReadObject(1,CODBPP::EQUALTO,&object,1,userName)) == NO_ERROR){
fixedObject = (struct FixedObject*)object.fixed;
swprintf(buffer,_T"First = %d, Second = %g", fixedObject->First, fixedObject->Second);
MessageBox(buffer);
}
}
}
if(error && database.GetErrorMessage(&message) == NO_ERROR)
MessageBox(message);
database.EndTransaction();
Also See
AddObject, NewObject,
DeleteObject, RestoreObject,
RewriteObject, SearchIndex
Copyright © 2003-2008, Ekky Software Pty. Ltd.