From the course: COBOL Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Relative files in COBOL - COBOL Tutorial
From the course: COBOL Essential Training
Relative files in COBOL
- [Instructor] To access records that are stored in a relative file, a relative record number or RRN must be provided. Supplying this number allows the record to be accessed directly, which saves time, because the system can use the start position of the file on disk and the size of the record and the relative record number to calculate the position of the record. Here's an image showing a disk and on that disk we have our file. We use the relative record number in this case four times the record length to get the offset for finding my record. It takes us directly to the record that we want. In order to demonstrate reading relative files, first we need to create one. Since it cannot be done using a regular text editor, I've written a small COBOL program that will read in a sequential file and save it as a relative file. Let's take a look. I'm going to switch over to Visual Studio. In your exercise files…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.