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 __int64 SearchIndex (
   unsigned int tableID,
   unsigned int index,
   const void *binaryKey,
   const void *tokenKey = NULL,
   bool acquireObjectLocks = false,
   __int64 *objectCount = NULL
unsigned __int64 SearchIndex (
   unsigned int tableID,
   unsigned int index,
   const void *binaryKey,
   unsigned int errorMargin,
   bool acquireObjectLocks = false,
   __int64 *objectCount = NULL


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.


  • 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
  • C++
#include "ODBPP.h"

#define TABLE_FIRST 1

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

int wmain(int argc, wchar_t* argv[])
   unsigned __int64 error;
   const char16_t *message;
   CODBPP database;
   CODBPP::Object object;
   int key[4] = {2,2,4,4}; // Key for a spatial tree index
   char16_t string[64];
   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,u"left = %d, top = %d, right = %d, bottom = %d",
            fixedObject->second.left, fixedObject->,
            fixedObject->second.right, fixedObject->second.bottom);
         error = database.ReadObject(TABLE_FIRST,CODBPP::NEXT,&object,1);
      if(ERROR_MASK(error) == CODBPP::NOT_FOUND_INDEX_KEY) error = NO_ERROR;
   if(error && database.GetErrorMessage(&message) == NO_ERROR)
   return NO_ERROR;

Also See

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