ABL combines procedural, database, and user interface statements
- Last Updated: December 14, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
|
The FOR EACH statement itself can be considered procedural,
because it defines an action within the program, in this case, repeating
a block of statements up to the END statement.
But the FOR EACH statement is also a database
access statement, because it defines a result set that the FOR EACH block
is going to iterate over, in this case, the set of all Customer records
in the database. This simple convention of combining procedural
logic with database access is a fundamental and enormously powerful
feature of ABL. In another language, you would have to define a
database query using a syntax that is basically divorced from the
procedural language around it, and then have additional statements
to control the flow of data into your procedure. In ABL, you can
combine all these elements in a way that is very natural, flexible,
and efficient, and relates to the way you think about how the program
uses the data.
The FOR EACH block is also powerful because
it transparently presents each record to your program in turn, so that the rest of the
procedural logic can act on it. If you have written applications that use the SQL language for
data retrieval, you can compare the ABL FOR EACH block with a
program in another language containing embedded SQL statements, where the set-based nature of
the SQL SELECT statement is not a good match to the
record-by-record way in which your program normally wants to interact with the data.
The DISPLAY statement shows that user
interface statements are also closely integrated with the rest of the program. ABL contains
language statements not only to display data, but also to create, update, and delete records,
and to assign individual values. All of these statements are fully integrated with the
procedural language. In later sections, you learn how to build your applications so that the
procedures that control the user interface are cleanly separated from the procedures that
manage the data and define your business logic.