Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : Defining a set of records to fetch
 

Defining a set of records to fetch

To fetch records, you must first define the set of records that you want ABL to fetch. For example, the following statement defines the set of all Customer records:
FOR EACH Customer:
ABL allows you to define a set of records in a variety of ways. You define the set of records in a Record phrase. For more information on the syntax of Record phrases, see OpenEdge Development: ABL Reference.
You can specify a Record phrase for the following ABL statements:
*FIND
*FOR [ EACH ]
*OPEN QUERY
*DO PRESELECT
*REPEAT PRESELECT
The examples that follow illustrate some of the flexibility that you have when defining a set of records. The Record phrases are highlighted. You can build complex Record phrases using the AND and OR operands.
This example defines a set of one record (Customer 11):
FIND Customer WHERE Customer.CustNum = 11.
This example uses the word-indexed field Comments to define a set of records (all Customer records containing the word "ship"):
FOR EACH Customer WHERE Customer.Comments CONTAINS "ship":
This example creates the subset of all Order records with the Customer number = 11:
OPEN QUERY ordqry FOR EACH Order WHERE Order.CustNum = 11.
This example defines a set of Customer records (those between 25 and 50) to be preselected:
REPEAT PRESELECT EACH Customer
  WHERE Customer.CustNum > 25 AND Customer.CustNum < 50: