Try OpenEdge Now
skip to main content
ABL Essentials
Procedure Blocks and Data Access : Language statements that define blocks : Data access without looping: the FIND statement : Doing a unique FIND to retrieve a single record
Doing a unique FIND to retrieve a single record
Very often you just need to retrieve a single record using selection criteria that identify it uniquely. In this case, you can use a FIND statement with no directional qualifier. For example, you can identify a Customer by its Customer number. This is a unique value, so you can use the following FIND statement:
FIND Customer WHERE Customer.CustNum = 1025.
DISPLAY Customer.CustNum Customer.Name Customer.Country.
The following figure shows the result.
Figure 22. Result of unique FIND
You need to be sure when you do this that only one record satisfies the selection criteria. Otherwise, you get an error at run time.
This is a shorthand for this FIND statement:
FIND Customer 1025.
You can use this shorthand form if the primary index is a unique index (with no duplication of values), the primary index contains just a single field, and you want to retrieve a record using just that field. You can use this form only when all these conditions are TRUE, so it's not likely to be one you use frequently. Also, this shorthand form makes it harder to determine your criteria. It can break if the data definitions change (for example, if someone adds another field to the CustNum index), so it's better to be more specific and use a WHERE clause to identify the record.