Here is what I found in the second memory. It looked like a random access to my thoughts. I wondered to see that right from IDENTIFICATION DIVISION it took me to COBOL data files. I thought of sharing it rather than putting it into the background. So here it comes. COBOL file or as a matter of fact any file is a collection of data stored on secondary storage device. In a broader perspective COBOL support three types of file organization.
- Sequential File
- Indexed File
- Random File
Sequential File stores the data in the same order in which the data data is provided by the user. Sequential file can be Line, Record or Printer sequential file. Organization of the data in file can be specified in code as:
SELECT MYFILE ASSIGN TO “MYFILE.DAT”
ORGANIZATION IS LINE SEQUENTIAL.
Organization can be otherwise RECORD SEQUENTIAL or PRINTER SEQUENTIAL. By default it is RECORD SEQUENTIAL.
Indexed File stores data using an Indexed key. Each record contains the primary key which is unique. In Indexed file you can store unique data. It can also be considered Master file or Master Data as we refer in COBOL. Separate file will be created with .idx extension to the data file. It will look something like this:
SELECT INDFILE ASSIGN TO “INDFILE.DAT”
ORGANIZTION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS IND-FILE-REC-KEY.
By the way, you have a facility to define DUPLICATE KEYS, in that case file can contain redundant data, but hold on, there is a limit which varies depending on type of Index file. Indexed file can be accessed or in other words I can say that data in Indexed file can be organized in three different ways i.e. INDEXED SEQUENTIAL (default, records are accessed on Ascending/Descending Record Key), INDEXED RANDOM (Value of Record Key is used to access the Record) and INDEXED DYNAMIC (Program can switch between Sequential or Random mode by using appropriate I/O statements).
Relative File identifies each record by ordinal position. This facilitates to access files sequentially or Randomly by using ordinal position in sequence or randomly. If you provide relative position while writing file as 1 and then 100, when you open this data file, can you imagine what will you see? Now, that it my question to you. I was fathomed by what I saw, it was interesting. Another interesting thing I noted while working on Relative files is that although I can create variable length records, System assume the size of largest record length and uses padding for unused spaces. The beneficial side is it brings speed. System can calculate the position of record to be accessed by using relative key and record length. So this is how it looks like:
SELECT MYRELFILE ASSIGN TO “MYRELFILE.DAT”
ORGANIZATION IS RELATIVE
ACCESS MODE IS RANDOM
RELATIVE KEY IS R-KEY.
Like Indexed file, Relative file can be accessed sequentially or randomly is ACCESS MODE is DYNAMIC.
Enjoy this read and look for more… Now what will be next…I have no idea, it depends, I need to decide whether I have to access my memory sequentially or randomly… have fun..