Input/output considerations for sequential-only processing
Here are the considerations for input/output operations on files when sequential-only processing is specified.
- For input, your program receives one record at a time from the input buffer. When all records in the input buffer are processed, the system automatically reads the next set of records.
Changes made after records are read into the input buffer are not reflected in the input buffer.
- For output, your program must move one record at a time to the output buffer. When the output buffer is full, the system automatically adds the records to the database.
If you are using a journal, the entire buffer is written to the journal at one time as if the entries had logically occurred together. This journal processing occurs before the records are added to the database.
If you use sequential-only processing for output, you might not see all the changes made to the file as they occur. For example, if sequential-only is specified for a file being used by PGMA, and PGMA is adding new records to the file and the SEQONLY parameter was specified with 5 as the number of records in the buffer, then only when the buffer is filled will the newly added records be transferred to the database. In this example, only when the fifth record was added, would the first five records be transferred to the database, and be available for processing by other jobs in the system.
In addition, if you use sequential-only processing for output, some additions might not be made to the database if you do not handle the errors that can occur when records are moved from the buffer to the database. For example, assume that the buffer holds five records, and the third record in the buffer had a key that was a duplicate of another record in the file and the file was defined as a unique-key file. In this case, when the system transfers the buffer to the database it would add the first two records and then get a duplicate key error for the third. Because of this error, the third, fourth, and fifth records in the buffer would not be added to the database.
- The force-end-of-data function can be used for output operations to force all records in the buffer to the database (except those records that would cause a duplicate key in a file defined as having unique keys, as described previously). The force-end-of-data function is only available in certain high-level languages.
- The number of records in a block will be changed to one if all of the following conditions are true:
- The member was opened for output-only processing or sequential-only processing.
- No override operations are in effect that have specified sequential-only processing.
- The file being opened is being extended because the increment number of records was set to zero.
- The number of bytes available in the file is less than the number of bytes that fit into a block of records.
Parent topic:
Sequential-only processing of database files