xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

REINDEX

Rebuilds all open indexes in the current work area.

Syntax

REINDEX [EVAL  <bBlock>] ;
        [EVERY <nInterval>]

Arguments

EVAL <bBlock>
This parameter is a code block that must return a logical value. The indexing operation continues as long as EVal(<bBlock>) returns .T. (true). The operation is stopped when Eval(<bBlock>) returns .F. (false).

The code block is evaluated for each record unless the EVERY option is specified. It is recommened to use EVERY in conjunction with EVAL.

EVERY <nInterval>
This option is a numeric value specifying the number of records after which the EVAL block is evaluated. This can improve the indexing operation especially for large databases. EVERY is ignored when no EVAL block is supplied.

Description

The REINDEX command rebuilds all open indexes in the current work area. During the operation the FOR condition, UNIQUE flag and ASCENDING/DESCENDING status defined with the INDEX command are maintained.

REINDEX requires a database be opened in EXCLUSIVE mode, otherwise a runtime error is generated. When the operation is complete, the first index becomes the controlling index and the record pointer is positioned on the first logical record.

Important:  REINDEX does not repair an index file header. If an index file gets corrupted, use the INDEX command to re-create index files from scratch.

Info

See also:INDEX, OrdCondSet(), OrdCreate(), OrdListRebuild(), PACK, SET INDEX, USE
Category: Database commands , Index commands
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// This example reindexes the indexes open in the current work area:

   PROCEDURE Main
      USE Customer INDEX Cust01, Cust02, Cust03 EXCLUSIVE

      REINDEX

      CLOSE Customer
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe