Using Range Find Routines
Range find routines only read the data for inquiry, not for update or modification.
The 850-FIND-BEGRNG-<Index> and 850-FIND-SUBRNG-<Index> are used for initial processing of data and the 850-FIND-MIDRNG-<Index> and 850-FIND-MIDSUBRNG-<Index> are used for repositioning within the initial cursor. To continue processing the cursor, once repositioning is done, the 860-FIND-NXTRNG-<Index> is used.
The 850-FIND-MIDRNG-<Index> and 850-FIND-MIDSUBRNG-<Index> , 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 850-FIND-NLT-<Index> and 860-FIND-NEXT-<Index> calls. The range find routines are better choices to use in many cases than 850-FIND-NLT-<Index> and 860-FIND-NEXT-<Index> , because the range find routines have some added performance advantages.
When 850-FIND-NLT-<Index> and 860-FIND-NEXT-<Index> calls combine to return a series of records, the database interface defines a range of records in a table. Once the 850-FIND-NLT-<Index> 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 a <FileName>-FOUND is returned 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, a <FileName>-NOTFOUND results, 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 860-FIND-NXTRNG-<Index> call causes the interface to return a <FileName>-NOTFOUND to the application. Also, in the case of 850-FIND-BEGRNG-<Index>, 850-FIND-SUBRNG-<Index>, and 860-FIND-NXTRNG-<Index>, you no longer need to fill the extra keys with zeros or spaces. (With 850-FIND-MIDRNG-<Index> and 850-FIND-MIDSUBRNG-<Index>, you still need to initialize the extra keys.)