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:
An existing keyed file has had the key structure modified and you did not elect to rebuild the file at that time.
An existing keyed file has been updated by routines that do not update the key structure. This is nearly impossible with any process above the level of the system debugger.
The system crashed during a file update and the key structure no longer matches the file structure.
The file integrity has been compromised due to a system malfunction such as a GFE.
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
Using Lookup and Browse Routines
Source Code to Lookup Routines
Maintaining Key File Performance
Stack Code Calculator Function