Creating Indexes

 

<< Click to Display Table of Contents >>

Navigation:  Getting Started >

 

Creating Indexes

 

Previous pageReturn to chapter overviewNext page

 

Btrieve Indexes may be on a single field or on multiple fields. Indexing on expressions is not supported.

A significant restriction for Btrieve indexing is that there is a limit on the number of index segments (fields) allowed in a Btrieve file. (See the Btrieve Programmer's Manual for details.) If the total segments of your indexes has reached the limit, you cannot, even temporarily, add another field or another index.

When you want to create indexes (both when you create a file and also afterwards) you need to tell VO2Btrieve the index information for the file in the following format:

 

-An array of BtIndex objects,
-A String or an array or strings containing the index definition(s).
If (an array of) string(s), it contains one entry for each field. The length of the string must be exactly 32 * the number of segment for the index. Each entry is a 32-byte string in the following format:

 

FFFFFFFFFFFFFFFFFFFFXXbbbDMNQSU; where:

F = field name (20)

X = literal text: "X "

b = blank filler (3)

D = 'D' if index is Descending

M = 'M' if there are More segments in index

N = 'N' if Nulls are allowed

Q = 'Q' if index is uniQue

S = 'S' if index is Static

U = 'U' if index is Uppercase

 

The field name should be a valid field name for the table.

 

Attributes D, M, N, Q, S, U are recognized only if they are uppercase; a lowercase letter can be left as a place holder when an attribute is not in effect.

 

Set MORE if the index is segmented (that is, contains more that one field). However, on the last segment, MORE must be set to False.

 

Set UNIQUE if the index is a unique key for the table. If the index is segmented, all segments in the index must have the same setting.

 

Set UPPERCASE if the field is case insensitive. Fields in a segmented index can have different settings of UPPERCASE. In addition, if a field participates in more than one index, it can have different settings of UPPERCASE.

 

Set DESCENDING if the field is to be indexed in descending order. Fields in a segmented index can have different settings of DESCENDING. In addition, if a field participates in more than one index, it can have different settings of DESCENDING.

 

Set NULLS if the key should not be indexed if the field(s) in the index are empty. If the index is segmented, all segments in the index must have the same setting.

 

Specifying NULLS can save disk space if a specific key will often be left empty. An example might be an index on an alternate phone number field, which often might not be entered by the user.

 

At least one index in a table must be left as NULLS = .F.

 

Set STATIC if the key value cannot be modified once the record has been added. (This will not affect empty keys where NULLS has been specified.) If the key is segmented, all segments in the index must have the same setting.