Use Basic ABL Constructs
- Last Updated: March 19, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
In Introduction to ABL, you learned some of the basic characteristics of ABL and you created a small test procedure. In this section you extend your test procedure.
Refining the data selection with a WHERE clause
So far you selected all the Customer records in the database. Now you 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 is 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 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:
- Add the following
WHEREclause to the end of yourFOR EACHstatement:FOR EACH Customer WHERE Customer.State = "NH": - 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.
- Add a sort expression to the end of your
WHEREclause to sort the Customers in order by their City. ABL uses the keywordBYto indicate a sort sequence. For example:FOR EACH Customer WHERE Customer.State = "NH" BY Customer.City: - Press F2 to run the procedure again to see the effects of your change.