Try OpenEdge Now
skip to main content
ABL Essentials
Using Basic ABL Constructs : Refining the data selection with a WHERE clause
 

Refining the data selection with a WHERE clause

So far you've been selecting all the Customer records in the database. Now you'll refine that selection to show only those Customers from the state of New Hampshire. There is a State field in the Customer table that holds the two-letter state abbreviation for states in the USA.
ABL supports a WHERE clause in any statement that retrieves data from the database, which will be familiar to you if you have used SQL or other similar data access languages. The WHERE keyword can be followed by any expression that identifies a subset of the data. You'll learn a lot more about this in later chapters, but for now a simple expression is all you need.
To refine the data selection in your test procedure:
1. Add the following WHERE clause to the end of your FOR EACH statement:
FOR EACH Customer WHERE Customer.State = "NH":
2. Press F2 to see the reduced list of Customers. The list should now use only a bit more than a page in the display window.
3. Add a sort expression to the end of your WHERE clause to sort the Customers in order by their City. ABL uses the keyword BY to indicate a sort sequence. For example:
FOR EACH Customer WHERE Customer.State = "NH" BY Customer.City:
4. Press F2 to run the procedure again to see the effects of your change.
* Comparison operators
* Using quotation marks