Technical data
6.14 Qualifying FIND and FETCH
You can locate records by using the contents of data items as search arguments.
You can use more than one qualifier as a search argument. For example, assume
you want to print a report of all employees in department 5 with a pay rate of
$7.50 per hour. You could use the department number as a search argument and
use a conditional test to find all employees with a pay rate of $7.50. Or you could
use both the department number and pay rate as search arguments, as follows:
.
.
.
000500 SETUP-QUALIFIES.
000510 MOVE 5 TO DEPARTMENT-NUMBER.
000520 MOVE 7.50 TO EMPLOYEE-RATE.
000530 FREE CURRENT.
000540 FETCH-EMPLOYEES.
000550 FETCH NEXT EMPLOYEE
000560 USING DEPARTMENT-NUMBER EMPLOYEE-RATE
000570 AT END GO TO EXIT-ROUTINE.
000580 PERFORM EMPLOYEE-PRINT.
000590 GO TO FETCH-EMPLOYEES.
.
.
.
You can also locate records by using a WHERE clause to designate a conditional
expression as a search argument. The following example fetches the first
SUPPLY record whose SUP_LAG_TIME is 2 days or less.
000450 FETCH-SUPPLY.
000460 FETCH FIRST SUPPLY
000470 WITHIN PART_INFO
000480 WHERE SUP_LAG_TIME LESS THAN 2
000490 AT END GO TO EXIT-ROUTINE.
DML Programming—Tips and Techniques 6–17