800-OPEN and 860-READ

The following two routines differ from all the other find routines in that they do not use indexes or keys to inquire on records. Instead, they directly access a file to inquire on the records.

The 800-OPEN-<FileName>and the 860-READ-<FileName> routines combine to inquire on an entire file in the order in which records are stored. Use these routines only when reading an entire file and order is not significant. No key fields are used with either of these routines because records are retrieved directly from the file with no need to identify individual key field values. This has the advantage of skipping the extra call to the <Index> for each record inquiry.

800-OPEN<FileName> readies the database to start reading records at the physical beginning of the file. If a connection to the database has not been established, the routine establishes it here. This routine also populates memory to hold the file description and any other memory required for the table to communicate to the database.

Once the 800-OPEN-<FileName> routine prepares the file, use the 860-READ-<FileName> routine to retrieve the records from the file in the physical order in which they are stored. Each time 860-READ-<FileName> is called, it returns the next record in the file. When the routine reaches the end of the file, the next call to 860-READ-<FileName> returns <FileName>-NOTFOUND.

Note: These routines are not valid while in transaction state.

Programming Example for Direct Inquiry Routines

The following example shows the direct inquiry routines inquiring on an entire file in its physical order.

* Open GLMASTER, then read and process one record at a time.
*
    PERFORM 800-OPEN-GLMASTER.
    PERFORM 860-READ-GLMASTER.
    PERFORM
        UNTIL (GLMASTER-NOTFOUND)
        PERFORM 999-PROCESS-GLM 
        PERFORM 860-READ-GLMASTER
    END PERFORM.

In this example, the 800-OPEN-<FileName> call readies the file for reading. The PERFORM loop then uses the 860-READ-<FileName> statement to continue reading and processing more records until it reaches the end of the file.