Page 1 of 1

variable length file

PostPosted: Sun Jan 02, 2011 5:02 am
by premv12
What's the advantage of VB file over FB file and when should one use VB file?

Re: variable length file

PostPosted: Sun Jan 02, 2011 7:06 am
by Robert Sample
A variable length record can reduce the amount of space required for a file. For example, I had an application one time where we needed to track job history records. The company had some highly mobile employees, so we had to allow for 125 job histories even though the average was less than 5. A fixed length record would have had on average 120+ blank job history records (which were something like 150 bytes each), so using variable length records cut -- literally -- over one billion bytes out of the file space required.

A variable length file should be used when use of one makes sense, or the application specifications state that it should be used. There's no hard and fast rule as to when to use variable length versus fixed length -- each application needs to be considered individually.

Re: variable length file

PostPosted: Sun Jan 02, 2011 8:32 am
by steve-myers
Mr. Sample's summary is excellent. Variable length records may prove to be more difficult to handle in Cobol than fixed length records, but don't let that dissuade you.

Most of my work has been in Assembler, and I use variable length records as a default, fixed length records only where they make a lot of sense, especially if the dataset is going to other programs after being sorted. If I had encountered Mr. Sample's example of a data structure, believe me, I would use variable length records. It takes quite a long time to pass over 1 billion essentially unused bytes in a dataset; better they're not there!

Re: variable length file

PostPosted: Sun Jan 02, 2011 9:58 am
by dick scherrer
Hello,

Mr. Sample's summary is excellent. Variable length records may prove to be more difficult to handle in Cobol than fixed length records, but don't let that dissuade you.
Definitely.

The 2 "reasons" i find people having difficulty with variable-length data are due to:
. really bad design
. fear/ignorance.

The space savings and i/o reduction can be quite substantial

Re: variable length file

PostPosted: Sun Jan 02, 2011 11:30 am
by premv12
Thanks a lot to all of you.