Find the proper child query in a ProDataSet
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
When a ProDataSet with data-relations binds
with a ProBindingSource, the ProBindingSource creates and maintains
a new child query for every expanded parent record in a hierarchical
grid. So, for each child table, you are likely to have not a single
query, but several different queries. The data-relation's CURRENT-QUERY( )method provides a way to find the child
query that corresponds to the currently selected parent record.
This attribute is useful when writing code to create, modify, or
delete child records.
For example, take the GetCurrentQuery function, shown
here:
|
You pass in a buffer name and the function matches
the name to one of the tables in the dsCustOrdOrdlines ProDataSet.
If the buffer is one of the child tables, the function uses the CURRENT-QUERY( ) method
to find the appropriate query and passes it back. For an example
of this technique, see UpdatableDataBindingGrid.p
(Part 4 of 11) in the Internal procedures and functions.
If the ProDataSet has a recursive data-relation, it presents an additional level of complexity. Because of the recursive data-relation, a single buffer name might be associated with several different bands in a hierarchical control. A band consists of all the records at a given level in the hierarchical display. This makes the buffer name insufficient to access the correct query.
To handle recursive data-relations,
you must specify the optional BandIndex parameter
when using the CURRENT-QUERY( ) method. The BandIndex property
indicates which level of the hierarchical display contains the currently
selected record. Using the BandIndex, the CURRENT-QUERY( ) method
can determine which query corresponds to the focused row in that
band.
The
following procedure is a CreateRow event handler
designed to handle a ProDataSet with a recursive data-relation.
First, it checks to see if the BandIndex is 0,
which always uses the top query. If not, it uses the BandIndex as
the parameter for the CURRENT-QUERY( ) method
to find the handle of the query that corresponds to the focused
row in that band.
|