Sets are used to access data sets. Each set is a collection of indexes or pointers to the records of a data set. An entry exists in the set for every record in the data set.
The organization of a set is separate from that of the data set it references. Several sets can be declared for a single data set and each can be organized differently and can specify different keys. This enables a data set to be accessed in several different ways.
The set declaration specifies the name of the set, the data set which the set references, the internal organization of the set, the set physical options, and the keys of retrieval, if any.
Sets are automatically maintained by the system. Records which are added to the data set are automatically added to the set. Similarly, records deleted from the data set are deleted from the set.
The following diagrams illustrate the syntax for declaring sets:
Set Declaration
──<set name>─┬───────────┬─ SET OF <data set name> ───────────────────► └─<comment>─┘ ►─┬──────────────────────────────────────────┬─┬────────────┬──────────► └─ REORGANIZE ─┬───────────────────────────┤ └─<set type>─┘ └─ ( KEY ─┬─ CHANGED ─┬─ ) ─┘ └─ SAME ────┘ ►─┬───────────────────────────────┬────────────────────────────────────┤ └─<set-subset physical options>─┘
<set type>
──┬─ BIT VECTOR ────────────────────────────────────┬──────────────────┤ ├─────────────┬─ LIST ─┬──────────────────────────┤ ├─ UNORDERED ─┘ └─<key data>───────────────┤ └─<key clause>─┬──────────────────────────────────┤ │ ┌◄───────────── , ─────────────┐ │ └─┴─┬─/1\─<duplicates>─────────┬─┴─┘ ├─/1\─<key data>───────────┤ └─/1\─┬─ INDEX RANDOM ─────┤ ├─ I-R ──────────────┤ ├─ INDEX SEQUENTIAL ─┤ ├─ I-S ──────────────┤ ├─ ORDERED LIST ─────┤ └─ O-L ──────────────┘
<key clause>
── KEY ─┬──────┬─┬─<key item>─────────────┬────────────────────────────┤ └─ IS ─┘ │ ┌◄──── , ────┐ │ └─ ( ─┴─<key item>─┴─ ) ─┘
<key item>
──┬─<field item name>───────┬─┬───────────────────────┬────────────────┤ ├─<group item name>───────┤ ├─ ASCENDING ───────────┤ ├─<numeric item name>─────┤ └─ DESCENDING ──────────┤ ├─<real item name>────────┤ │ ├─<record type item name>─┤ │ ├─<RSN item name>─────────┘ │ └─<alpha item name>─┬──────────────┬─┬──────────────┤ ├─ ASCENDING ──┤ └─<comparison>─┘ └─ DESCENDING ─┘
<comparison>
──┬─ BINARY ─┬─────────────────────────────────────────────────────┬───┤ │ └─ COMPARISON ────────────────────────────────────────┤ ├─ LOGICAL ────┬─┬──────────────┬─┬──────────────────────────────┤ └─ EQUIVALENT ─┘ └─ COMPARISON ─┘ └─ ( ──<unsigned integer>── ) ─┘
<duplicates>
──┬─ DUPLICATES ─┬──────────────────┬──────────────────────────────────┤ │ ├─ FIRST ──────────┤ │ └─ LAST ───────────┤ └─ NO DUPLICATES ─┬───────────────┤ └─ KEYCHANGEOK ─┘
<key data>
── DATA ─┬─<key data item>─────────────┬───────────────────────────────┤ │ ┌◄─────── , ──────┐ │ └─ ( ─┴─<key data item>─┴─ ) ─┘
<key data item>
──┬─<alpha item name>───┬──────────────────────────────────────────────┤ ├─<Boolean item name>─┤ ├─<field item name>───┤ ├─<group item name>───┤ ├─<numeric item name>─┤ ├─<real item name>────┤ └─<RSN item name>─────┘
The set-subset physical options are discussed under “Set and Subset Physical Options” later in this section. The remaining elements of the syntax diagram are discussed in the following text.