Monday, 28 July 2014

COBOL Sequential File Organization

In this type of file, the records are stored in consecutive disk locations. For efficiency, these files are usually blocked so a large block of records is read or written at one time.

When the records in a sequential file are processed, they usually need to be in sequence by one or more of the fields in the records. These fields are referred to as the key fields. Sometimes, a sequential file is created with the records in the proper key sequence. 

Sometimes, a sequential file needs to be sorted into the proper sequence before it can be processed.

Example : Employee sequential file.


In case of Line sequential ORGANIZATION, each record contains a sequence of characters ending with a record terminator. The terminator is not counted in the length of the record. 

When records are written to a line sequential file, the trailing blanks (if any) are removed and while reading the record from a line sequential file, characters are read one at a time into the record buffer until the first record terminator is encountered. It is important to note that Line sequential ORGANIZATION is available only on workstations.

Performace Tips:

The trouble with sequential files is that you have to read them in sequence. As a result, there’s no way to read the 200th record in a file without first reading the first 199 records. 

But that means that sequential files can’t take advantage of the disk drive’s ability to read any sector on a direct, or random, basis.

To improve I/O efficiency, the records in sequential files are usually blocked with a large blocking factor.


Created with Artisteer

No comments:

Post a comment