Synergy sequential files
Synergy sequential files are used to access records sequentially from the beginning of the file to the end of the file. Records are not accessed randomly. The physical file format varies slightly on each operating system.
On Windows and UNIX, Synergy DBMS accesses records in sequential files. We do not recommend placing binary data in the records, as the size of each record is determined by the placement of the record terminator and the binary data can be mistaken for the record terminator.
On OpenVMS, the RMS file system is used for native compatibility. The records can contain binary data because RMS knows the length of each record and does not depend on the record terminator to separate each record. When the file is opened, the record type is automatically retrieved.
To support terabyte sequential files, both the operating system and file system must be 64 bit.
Sequential file structure
On Windows and UNIX, a sequential file consists of a byte stream where the end of each record is defined by the location of the record terminator. On Windows, the record terminator is normally a CR-LF (carriage return and line feed) byte pair but can also be a single LF byte. On UNIX, the record terminator is a single LF (line feed) byte. On either system, a record terminator can also be a VT (vertical tab) byte or an FF (form feed) byte.
On OpenVMS, a sequential file is a specific RMS file type. Each record consists of only the data without record terminators.
Sequential file types
On Windows and UNIX, there is only one sequential file type: a byte stream where the records are defined by the placement of the record terminator.
On OpenVMS, sequential files can either contain fixed-length records or variable-length records depending on how the record format for the file was specified when it was created. The maximum size of a record in a sequential file is 65,535 bytes. The records in a sequential file are preceded by two bytes that specify the length of the record, and if the record length is odd, a null byte follows the record. RMS masks this physical format of the file so only the data is stored or retrieved.
To create a sequential file, specify the mode as O:S or A:S on the OPEN statement. On OpenVMS, if the mode is specified as O or A without a submode, and the program was either not compiled with the /STREAM switch or the OPTIONS=“/STREAM” qualifier was not specified, the file is created as a sequential file. To open an existing sequential file, specify the mode as I:S, U:S, or A:S on the OPEN statement.
Record access
Records are accessed sequentially from the first record through the end of the file.
Sequential record input and output statements
This section lists the primary input and output statements and describes how their use affects sequential files. System-specific differences are also listed. See Synergy DBL Statements for more information about other statement qualifiers that are not specific to sequential file access.
READS statement
reads(channel, record, eof_label)
The READS statement retrieves the next sequential record in the file.
On Windows or UNIX, a READS statement retrieves data from the file based on the size of the destination field plus the size of a record terminator and then searches the data for the record terminator. The data up to the record terminator is transferred to the destination field and left-justified over blanks.
WRITES statement
writes(channel, record)
The WRITES statement writes the record plus the record terminator to the file at the current location. If the file is opened in U:S mode, the WRITES statement can be used for updating the record that was previously read.
FIND statement
find(channel, , , POSITION:Q_BOF)
The FIND statement repositions to the beginning of the file.
%RSIZE function
size = %rsize
The %RSIZE (or %RDLEN) function returns the size of the last record read but does not include the record terminator. The returned value is for the last operation, regardless of the channel used.
%RTERM function
value = %rterm
For READ and READS operations, %RTERM (or %RDTRM) returns the record terminator of the last operation, regardless of the channel used.
Record locking
Record locking occurs by default if the file is opened in U:S mode unless the LOCK:Q_NO_LOCK option is specified. The READS statement causes the previous record to be unlocked and the record specified by the statement to be locked.