KEY (declare dynamic file access index)

Top  Previous  Next

 

label

KEY([-/+]field,...,[-/+][field]) [,DUP] [,NAME( )] [,NOCASE] [,OPT] [,PRIMARY]

label

The label of the KEY (PROP:Label).

KEY

Declares a dynamically maintained index into the data file.

-/+

The - (minus sign) preceding a key component field specifies descending order for that component. If omitted, or + (plus sign), the component is sorted in ascending order.

field

The label of a field in the RECORD structure of the FILE in which the KEY is declared. The field is a key component. A field declared with the DIM attribute (an array) may not be used as a key component.

NAME

Specifies the disk file specification of the KEY (PROP:NAME).

DUP

Allows multiple records with duplicate values in their key component fields (PROP:DUP).

NOCASE

Specifies case insensitive sort order (PROP:NOCASE).

OPT

Excludes, from the KEY, those records with null (zero or blank) values in all key component fields (PROP:OPT).

PRIMARY

Specifies the KEY is the file's relational primary key (a unique key containing all records in the file) (PROP:PRIMARY).

A KEY is an index into the data file which is automatically updated whenever records are added, changed, or deleted. It is used to access records in a different logical order than the "physical order" of the file. A KEY may be used for either sequential file processing or direct random access.

A KEY may have more than one component field. The order of the components determines the sort sequence of the key. The first component is the most general, and the last component is the most specific. Generally, a data file may have up to 255 keys (and indexes) and each key may be up to 255 bytes, but the exact numbers are file driver dependent.

Example:

Names   FILE,DRIVER('Clarion'),PRE(Nam)

NameKey  KEY(Nam:Name),NOCASE,DUP    !Declare the name key

NbrKey   KEY(Nam:Number),OPT         !Declare the number key

Rec      RECORD

Name      STRING(20)

Number    SHORT

        END

       END

CODE

Nam:Name = 'Soft Velocity'          !Initialize key field

GET(Names,Nam:NameKey)              !Get the record

SET(Nam:NbrKey)                     !Set sequential by number

 

See Also:

SET

GET

INDEX

BUILD

PACK