Home > Software > Mainframe > Cobol
Interview Questions   Tutorials   Discussions   Programs   

Cobol - What is the difference between the variable length and fixed lenght.how it varies in the Cobol?




1125
views
asked mar September 9, 2014 11:10 AM  

What is the difference between the variable length and fixed lenght.how it varies in the Cobol?


           

1 Answers



 
answered By Mswami   0  

A file can contain:

  • Fixed-length records - all the records are exactly the same length
  • Variable-length records - the length of each record varies.

Using variable-length records might enable you to save disk space. When you use fixed-length records, you need to make the record length equal to the length of the longest record. If your application generates many short records with occasional long ones, using fixed-length records wastes a lot of disk space, so variable-length records would be a better choice.

A file where all the records are of the same length is said to have fixed length records.

Advantage : Access is fast because the computer knows where each record starts. Eg If each record is 120 bytes long then the 1st record starts at [Start of File] + 0 bytes the 2nd record starts at [Start of File] + 120 bytes the 3rd record starts at [Start of File] + 240 bytes etc.....

Disadvantage : Using Fixed length records, the records are usually larger and therefore need more storage space and are slower to transfer (load or save). One or more of the fields can be of differing lengths in each record, called variable length records.

Advantages: The records will be smaller and will need less storage space the records will load faster.

Disadvantages: The computer will be unable to determine where each record starts so processing the records will be slower.

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert