Using joins instead of nested reads
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
Using joins instead of nested reads
Using joins provides an opportunity for the AVM to optimize the
retrieval of records from multiple related tables using the selection
criteria you specify. When you perform a nested read, for example
using nested FOR EACH statements
for different tables, you are actually implementing a join in an
ABL procedure. However, by specifying one or more contiguous joins
in a single FOR EACH statement
or in the PRESELECT phrase of single DO or REPEAT statement,
you minimize the complexity of your ABL code and leave the complexity
of joining tables to the ABL interpreter.
For a single ABL query (OPEN QUERY statement),
there is no other way to retrieve data from multiple tables except
by using joins. With both inner and left outer join capability,
you can use the OPEN QUERY statement
to implement most queries that are possible using nested FOR EACH, DO,
or REPEAT statements. As such, query joins provide
the greatest opportunity for optimized multi-table record retrieval
in ABL. Also, because browse widgets read their data from queries,
you must use query joins to display multiple related tables in a
browse.
However, use nested FOR EACH, DO,
and REPEAT blocks wherever you require much finer
control over how you access and manipulate records from multiple
tables.