Dynamic access

For dynamic access, code ACCESS IS DYNAMIC in the FILE-CONTROL paragraph.

Dynamic access supports a mixture of sequential and random access in the same program. With dynamic access, you can use one COBOL file definition to perform both sequential and random processing, accessing some records in sequential order and others by their keys.

For example, suppose you have an indexed file of employee records, and the employee's hourly wage forms the record key. Also, suppose your program is interested in those employees who earn between $12.00 and $18.00 per hour and those who earn $25.00 per hour and above. To access this information, retrieve the first record randomly (with a random-retrieval READ) based on the key of 1200. Next, begin reading sequentially (using READ NEXT) until the salary field exceeds 1800. Then switch back to a random read, this time based on a key of 2500. After this random read, switch back to reading sequentially until you reach the end of the file.

Related concepts  
Sequential access  
Random access