C Examples: DbiAddIndex

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

C Examples: DbiAddIndex

Return to chapter overview

Example 1: Add an index to a Paradox 4.0 or 5.0 version table:

Note: This is a primary index.

 

DBIResult fDbiAddIndex1(hDBIDb hTmpDb, hDBICur hTmpCur)

{

   DBIResult   rslt;

   IDXDesc     NewIndex;

   DBIKEY      aiKeys = { 1 };   // Field to put index on

 

   NewIndex.iIndexId = 0;

   NewIndex.bPrimary = TRUE;

   NewIndex.bUnique = TRUE;

   NewIndex.bDescending = FALSE;

   NewIndex.bMaintained = TRUE;

   NewIndex.bSubset = FALSE;

   NewIndex.bExpIdx = FALSE;

   NewIndex.iFldsInKey = 1;

   memcpy(NewIndex.aiKeyFld, aiKeys, sizeof(DBIKEY));

   NewIndex.bCaseInsensitive = FALSE;

   rslt = Chk(DbiAddIndex(hTmpDb, hTmpCur, NULL, NULL, &NewIndex, NULL));

 

   return rslt;

}

 

Example 2: Add an index to a Paradox 4.0 or 5.0 version table:

Note: This is a case-insensitive, secondary, maintained index:

 

DBIResult fDbiAddIndex2(hDBIDb hTmpDb, hDBICur hTmpCur)

{

   DBIResult   rslt;

   IDXDesc     NewIndex;

   DBIKEY      aiKeys = { 2 };   // Field to put index on

 

   strcpy(NewIndex.szName, "TempIndex");

   NewIndex.bPrimary = FALSE;

   NewIndex.bUnique = FALSE;

   NewIndex.bDescending = FALSE;

   NewIndex.bMaintained = TRUE;

   NewIndex.bSubset = FALSE;

   NewIndex.bExpIdx = FALSE;

   NewIndex.iFldsInKey = 1;

   memcpy(NewIndex.aiKeyFld, aiKeys, sizeof(DBIKEY));

   NewIndex.bCaseInsensitive = TRUE;

   rslt = Chk(DbiAddIndex(hTmpDb, hTmpCur, NULL, NULL, &NewIndex, NULL));

 

   return rslt;

}

 

Example 3: Add an index to a dBASE for Windows version table:

 

DBIResult fDbiAddIndex3(hDBIDb hTmpDb, hDBICur hTmpCur)

{

   DBIResult   rslt;

   IDXDesc     NewIndex;

   DBIKEY      aiKeys = { 2 };   // Field to put index on

 

   strcpy(NewIndex.szTagName, "TestIndex");

   NewIndex.bPrimary = FALSE;

   NewIndex.bUnique = FALSE;

   NewIndex.bDescending = FALSE;

   NewIndex.bMaintained = TRUE;

   NewIndex.bSubset = FALSE;

   NewIndex.bExpIdx = FALSE;

   NewIndex.iFldsInKey = 1;

   memcpy(NewIndex.aiKeyFld, aiKeys, sizeof(DBIKEY));

   strcpy(NewIndex.szKeyExp, "");   // Although this is not an Expression index,

   strcpy(NewIndex.szKeyCond, "");  // szKeyExp and szKeyCond must be set blank

   NewIndex.bCaseInsensitive = FALSE;

   NewIndex.iBlockSize = 0;

 

   rslt = Chk(DbiAddIndex(hTmpDb, hTmpCur, NULL, NULL, &NewIndex, NULL));

   return rslt;

}

 

Example 4: Add an expression index to a dBASE for Windows version table:

 

DBIResult fDbiAddIndex4(hDBIDb hTmpDb, hDBICur hTmpCur, char *Expression)

{

   DBIResult   rslt;

   IDXDesc     NewIndex;

   DBIKEY      aiKeys = { 0 };   // Field to put index on

 

   strcpy(NewIndex.szTagName, "ExpIndex");

   NewIndex.bPrimary = FALSE;

   NewIndex.bUnique = FALSE;

   NewIndex.bDescending = FALSE;

   NewIndex.bMaintained = TRUE;

   NewIndex.bSubset = FALSE;

   NewIndex.bExpIdx = TRUE;

   NewIndex.iFldsInKey = 0;

   memcpy(NewIndex.aiKeyFld, aiKeys, sizeof(DBIKEY));

   strcpy(NewIndex.szKeyExp, Expression);

   strcpy(NewIndex.szKeyCond, "");

   NewIndex.bCaseInsensitive = FALSE;

   NewIndex.iBlockSize = 0;

 

   rslt = Chk(DbiAddIndex(hTmpDb, hTmpCur, NULL, NULL, &NewIndex, NULL));

   return rslt;

}