Sorting the query results
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
Sorting the query results
You can specify a BY phrase on your OPEN
QUERY statement just as you can in a FOR EACH block.
In this case, the AVM either uses an index to satisfy the sort order
if possible or, if no index can allow the AVM to retrieve the data
in the proper order, preselects and sorts all the query results before
any data is made available to the application.
Over a series of query iterations, you might want to do some
work based on whether the value of a certain field changes. This
field defines a break group. For example, you might be accumulating
some value, such as a total. In this example, the BREAK option
is used to define Customer.State as the break group:
|
When using the BREAK option you must also use
the BY option to name a sort field.
Note: To test whether a break group has changed, you can use the
FIRST-OF( ) and LAST-OF( ) methods of the query object handle. For more information on the
query object handle, see ABL Reference.