In the ENVIRONMENT Division For a KSDS:
SELECT file-name ASSIGN TO UT-ddname ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL / RANDOM / DYNAMIC RECORD KEY IS data-name-1 ALTERNATIVE RECORD KEY IS data-name-2 WITH DUPLICATES FILE-STATUS IS data-name-3 data-name-4
- The RECORD KEY clause specifies the data item within the record that is the prime record key for the indexed file. The value contained in this data item must be unique among records in the file. Data-name-1 must be described as an alphanumeric item within the record description. An IBM extension allows data-name-1 to be defined to be numeric, numeric-edited, alphanumeric-edited or alphabetical though the key is still treated as an alphanumeric item for the input and output statements for the named file.
- The same rules apply to the ALTERNATE RECORD KEY clause as in note 1. Data-name-2 must not be at the same position on the record as the primary index key or any other alternate record key field.
- If the DUPLICATE clause is specified, the values contained in the ALTERNATE RECORD KEY data item may be duplicated within any records in the file. In sequential access, the records with duplicate keys are retrieved in the order in which they were placed in the file. In random access, only the first record written of a series of records with duplicate keys can be retrieved.
SELECT MASTER-FILE ASSIGN TO UT-KSDSMAST ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS MAT-EMP-NO ALTERNATE RECORD KEY IS MAST-EMP-DEPT WITH DUPLICATES FILE STATUS IS STATE-CODE VSAM-RETURN-CODE