Using Range Find Routines
Range find routines only read the data for inquiry, not for update or modification.
The E@DBFINDBEGRNG and E@DBFINDSUBRNG are used for initial processing of data and the E@DBFINDMIDRNG and E@DBFINDMIDSUB are used for repositioning within the initial cursor. To continue processing the cursor, once repositioning is done, the E@DBFINDNXTRNG is used.
The E@DBFINDMIDRNG and E@DBFINDMIDSUB, with their ability to reposition within a cursor, are useful for screen scrolling (page up and page down) within online programs, recovery of batch jobs, and continuation after a transaction end in online programs where the end of the main transaction does a close of all open cursors
Performance Advantages in Using Range Find Routines
The Range Find routines perform similarly to the E@DBFINDGE and E@DBFINDNXT calls. The range find routines are better choices to use in many cases than E@DBFINDGE and E@DBFINDNXT, because the range find routines have some added performance advantages.
When E@DBFINDGE and E@DBFINDNXT calls combine to return a series of records, the database interface defines a range of records in a table. Once the E@DBFINDGE call declares a range and retrieves the first record in the set, the application checks the record to see if it matches the keys passed in the call. If it does, the application continues on and processes the next record as long as D<prefix>@NOTFOUND is set to FALSE during each check. Unfortunately, this check condition means that the database still needs to return another record even after the end of the appropriate range of records has been reached.
To accomplish this, the interface drops the last key and opens another range, using it to return a record that fails the check. When the application gets this record, D<prefix>@NOTFOUND is set to TRUE, ending the processing of the records.
The range find calls solve the problem of the second range by placing the check in the interface logic. In this case, once the end of the desired range is reached, the next E@DBFINDNXTRNG call causes the interface to set D<prefix>@NOTFOUND to TRUE. Also, in the case of E@DBFINDBEGRNG, E@DBFINDSUBRNG, and E@DBFINDNXTRNG, you no longer need to fill the extra keys with zeros or spaces. (With E@DBFINDMIDRNG and E@DBFINDMIDSUB, you still need to initialize the extra keys.)