WRITE Statement:
The WRITE statement for a relative file has the format which is as shown below.
WRITE record-name [ FORM identifier ]
[ ; INVALID KEY imperative statement ]
At the time of the execution of WRITE statement, the file should be open either in the OUTPUT or I-O mode. For illustration, assume REL-OUTPUT AND REL-KEY are the record name and relative key data item name for a relative file opened in the I-O mode. Then, upon execution of the statements below:
MOVE 50 TO REL-KEY.
WRITE REL-OUTPUT INVALID KEY GO TO PARA-INVALID.
The record is written at the 50th record location on the file.
The imperative statement of INVALID KEY phrase is the execution in the situation as shown below:
(i) When a try is made to write beyond the externally-defined boundaries of the file.
(ii) When a try is made to write in the record place that already contains a valid record.