Relative File

From VSI OpenVMS Wiki
Jump to: navigation, search

A relative file is a type of file organization that allows sequential and random access of records. A relative file consists of a series of numbered fixed-length records; RMS uses the relative record number - the record's position relative to the beginning of the file - to randomly access records. Relative files allow random get and put operations and can be write-shared. In relative files, all records are in fixed-length cells regardless of their format.

To find out if a file is relative, use DIRECTORY/FULL or the F$FILE_ATTRIBUTES() lexical: F$FILE_ATTRIBUTES(filespec,"ORG") will return "REL".

Sequential Access

Relative files may be accessed sequentially even if some of the fixed-length file cells are empty (because records were never stored in them or because records were deleted from them). RMS ignores empty cells and sequentially searches for the next occupied cell. For example, assume a relative file contains records only in cells 1, 3, and 6. RMS responds to a sequential retrieval request by retrieving the record in cell 1, then the record in cell 3, and then the record in cell 6.

Relative Access

RMS supports random access for all relative files, all indexed files, and a restricted set of sequential disk files - those having fixed-length records. In random access mode, your program (not the file organization) determines the record processing order. For example, to randomly access a record in a relative file or a record in a sequential disk file having fixed-length records, your program must provide the relative record number of the cell containing the record.

See also