DbiRegenIndex

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

DbiRegenIndex

Return to chapter overview

C syntax

DBIResult DBIFN DbiRegenIndex (hDb, [hCursor], [pszTableName], [pszDriverType], pszIndexName, pszIndexTagName, iIndexId);

Delphi syntax

function DbiRegenIndex (hDb: hDBIDb; hCursor: hDBICur; pszTableName: PChar; pszDriverType: PChar; pszIndexName: PChar; pszIndexTagName: PChar; iIndexId: Word): DBIResult stdcall;

Description

DbiRegenIndex regenerates an index to ensure that it is up to date (all records currently in the table are included in the index and are in the index order). It can also be used to pack the index on disk.

Parameters

hDb                Type: hDBIDb                (Input)
Specifies the database handle associated with the database where the table exists.

hCursor                Type: hDBICur                (Input)
Specifies the cursor on the table. Optional. If hCursor is specified, the operation is performed on the table associated with the cursor. If hCursor is NULL, pszTblName and pszDriverType determine the table to be used.

pszTableName                Type: pCHAR                (Input)
Pointer to the table name. Optional. If hCursor is NULL, pszTableName and pszDriverType determine the table to be used. If both pszTableName and hCursor are specified, pszTableName is ignored.

For Paradox, FoxPro, and dBASE, if pszTableName is a fully qualified name of a table, the pszDriverType parameter need not be specified. If the path is not included, the path name is taken from the current directory of the database associated with hDb.

pszDriverType                Type: pCHAR                (Input)
Pointer to the table type. Optional. For Paradox, FoxPro, and dBASE tables, this parameter is required if pszTableName has no extension. pszDriverType can be one of the following values: szDBASE or szPARADOX.

pszIndexName                Type: pCHAR                (Input)
Pointer to the name of the index. See rules for naming indexes in the IDXDesc section.

pszIndexTagName                Type: pCHAR                (Input)
Pointer to the tag name of the index in a .MDX or .CDX file. Used for dBASE and FoxPro tables only. This parameter is ignored if the index given by pszIndexName is not a .MDX or .CDX index.

iIndexId                Type: UINT16                (Input)
Specifies the index number.

Usage

iIndexId, pszIndexName, and pszIndexTagName are used in various combinations to specify the index to regenerate.

Important:        A maintained index is automatically updated when the table is updated. A non-maintained index must use DbiRegenIndex to update the index after the table is modified before it can be used to access data.

Paradox: The effect of regenerating a maintained index is that it becomes more efficient and compact. (Frequent updates can fragment an index.)

SQL, Access: SQL and Access indexes cannot be regenerated.

dBASE and FoxPro: DbiRegenIndex is normally used to update a non-maintained dBASE or FoxPro index. However, there may be situations when a maintained index needs to be regenerated. Since a non-production index is maintained only when it is in use, it is not actually maintained at all times. If the index is not up to date, DbiRegenIndex can be used to synchronize the index with the current data.

Prerequisites

The table name must be provided and the index must already exist. When regenerating a maintained index, the table must be opened exclusively. When regenerating a non-maintained index, BDE must be able to obtain a write lock on the table.

DbiResult

Meaning

DBIERR_NONE

The index specified by pszIdxName was successfully regenerated.

DBIERR_NOSUCHINDEX

The given index (pszIdxName) does not exist.

DBIERR_INVALIDPARAM

A cursor was not provided for the table, and the table name is either empty or not provided.

DBIERR_INVALIDHNDL

The specified handle was invalid or NULL.

DBIERR_NEEDEXCLACCESS

A cursor was provided for the table, but it was not opened in exclusive mode when regenerating a maintained index.

DBIERR_FILEBUSY

Exclusive access could not be obtained on table.

DBIERR_FILELOCKED

Write lock could not be obtained on table.

DBIERR_NOTSUPPORTED

A SQL index cannot be regenerated.

See also

DbiRegenIndexes