SearchIndex

SearchIndex creates a temporary internal index that contains all matching objects to the search. Once the internal index is created, you can use ReadObject or DeleteObject, with the search modes to read in the objects.
unsigned int SearchIndex (
   unsigned int tableID,
   unsigned int index,
   const void *binaryKey,
   const void *tokenKey = NULL,
   bool acquireObjectLocks = false,
   __int64 *objectCount = NULL
);
unsigned int SearchIndex (
   unsigned int tableID,
   unsigned int index,
   const void *binaryKey,
   unsigned int errorMargin,
   bool acquireObjectLocks = false,
   __int64 *objectCount = NULL
);

Parameters

tableIDthe table ID defining the table's handle.
indexthe index value, 0 for object ID hash index is invalid, 1 for the first defined index.
binaryKeythe buffer containing the binary key value used in the search of a CODBPP::S_TREE, or the binary section of a CODBPP::A_LIST or a CODBPP::W_LIST key search.
tokenKeythe buffer containing the token section for a CODBPP::A_LIST or a CODBPP::W_LIST key search. This variable is of type void beacuse for a CODBPP::A_LIST the string should be in ASCII format, while for a CODBPP::W_LIST it should be a wide character string.
errorMarginused for search Spatial Pattern indexes, allowing for matching patterns with the error margin.
acquireObjectLockswith this set to true, this method will acquire all object locks before returning NO_ERROR, else the read method will acquire the object lock.
objectCountthe total amount of object found in the search.

Return Values

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

Remarks

  • This method is used for seaching indexes of index type CODBPP::S_TREE, CODBPP::A_LIST and CODBPP::W_LIST.
  • SearchIndex will not return an error if there are no matching results for the search, read the first object to see if there is or not, any results matching the search.
Example Use
#define TABLE_FIRST 1
CODBPP::Object object;
struct FixedObject{
   int First;
   RECT Second;
} *fixedObject;
int key[4] = {2,2,4,4}; // Key for a spatial tree index
char16_t string[64], *message;
if((error = database.BeginTransaction()) == NO_ERROR
&& (error = database.OpenTable(TABLE_FIRST)) == NO_ERROR
&& (error = database.SearchIndex(TABLE_FIRST,1,key)) == NO_ERROR){
   error = database.ReadObject(TABLE_FIRST,CODBPP::FIRST,&object,1);
   while(error == NO_ERROR){
      fixedObject = (struct FixedObject*)object.fixed;
      swprintf(string,TEXT("left = %d, top = %d, right = %d, bottom = %d"),
         fixedObject->second.left, fixedObject->second.top,
         fixedObject->second.right, fixedObject->second.bottom);
      MessageBox(string);
      error = database.ReadObject(TABLE_FIRST,CODBPP::NEXT,&object,1);
   }
   if(error == (0x10000 | CODBPP::NOT_FOUND_INDEX_KEY)) error = NO_ERROR;
}
if(error && database.GetErrorMessage(&message) == NO_ERROR)
   MessageBox(message);
database.EndTransaction();

Also See

DeleteObject, ReadObject
Comments (0)Listen All
Characters left: 2500
 
Ekky Software Homepage Ekky Software Homepage ObjectDatabase++ TScript Ekky Software Homepage Ekky Software Homepage ObjectDatabase++ TScript