Rebuilding Keys

In order to utilize the key files, they must initially be built from the data portion.

Rebuilding All Keys

This function is accomplished automatically by the CREATE-KEYFILE TCL command. In addition, you may utilize the KEY-REBUILD command to optionally rebuild the keys should they ever become damaged.

Format

KEY-REBUILD filename

This command automatically rebuilds all of the defined keys for the file specified. It should be used in the following circumstances:

It is not necessary to rebuild the key structure unless one of the above events has occurred. The key routines are designed to automatically rebalance the key structure to account for additions, edits, deletions, and to maintain an efficient organization without periodic rebuilding.

KEY-COUNT Command

A command is provided within BTREEs to count keys. This command can replace the ACCESS COUNT command in many situations and executes faster.

Format

KEY-COUNT file keyname {key1 {key2}} (V}

The (V option causes a running numeric total to be displayed.

The number of items in the key are counted and the result displayed. If key1 and key2 are included, then the count begins and ends at those key values.

NOTE

The KEY-COUNT command counts keys and not items; if the key is MultiValued, it counts the number of values.

KEY-SELECT Command

The KEY-SELECT command is provided to build SELECT lists based upon BTREE keys.

Format

KEY-SELECT file keyname {key1 {key2}} (V}

The (V option causes a running numeric total to be displayed.

The KEY-SELECT command creates an ACCESS SELECT list for all items in the file in the order of the specified keyname and between the key values of key1 and key2. If the key values are omitted, then the entire file is selected.

The KEY-SELECT command has the same uses as the ACCESS SSELECT command, and the lists returned by it are fully usable by all of the commands that SSELECT is compatible with, including SAVE-LIST, etc.

See Also

Using the BTREE File Structure System

BTREE File Structure

Interfacing with Applications

Defining Key Structures

Using Lookup and Browse Routines

Source Code to Lookup Routines

Maintaining Key File Performance

Optimizing Keys

Sizing Key Files

Stack Code Calculator Function

Estimating a Key's Location and File Size

Key Storage Requirements