READ for ISAM-A

READ #ch, recvar

READL #ch, recvar

READ'READ'ONLY #ch, recvar

The READ statement variants listed above, normally reserved for random files, may also be used with ISAM-A files.

One reason why you might want to use READ instead of one of the GET statement variants would be in a situation where you have previously read a record with GET'NEXT and now want to lock it so that it can be deleted or updated. Normally you would use GET'LOCKED; but if all the indexes allow duplicate keys, there may not be any easy and efficient way to re-locate the current record. In that case, READL would work.

For example, the following code illustrates scanning a file looking for records with specific attributes to be deleted. If the file is large, and the number of records to be deleted is small, and the index accepts duplicates, then it might be more efficient to scan the file with GET'NEXT'READ'ONLY, using an extra READL for the few records to be deleted, than to scan the entire file using GET'NEXT'LOCKED followed by a RELEASE'RECORD for all of the records we aren't going to delete.

do

    get'next'read'only #ch, rec

    if fstat = ISAM_EQ then   

        if <rec data meets some condition> then

            readl #ch, rec     ! re-read the record with the lock set

            delete'record #ch

        endif

    else

        exit

    endif

loop

 

See READ (for Random files) for more details on READ statements.