Release 10.1A: OpenEdge Development:
ProDataSets

> ## Using the REPOSITION Data-Relation

> You can include the optional keyword `REPOSITION` on a Data-Relation definition that is part of a ProDataSet definition. As you will later see, there is also a `REPOSITION` logical attribute on a Data-Relation handle that lets you set this mode on or off at run time.

> The purpose of the reposition mode on a relation is to handle the situation where you want to load a limited set of child records into a ProDataSet table that is related to possibly multiple parent rows of another table in the ProDataSet. For example, you might want to include a separate State table with state abbreviation and full state name in your ProDataSet rather than joining that information into each individual `Customer` or `Order` record in the ProDataSet. Or you might want to include an `Item` table with all available `Items` in your ProDataSet and be able to join an `Item` to all of the `OrderLines` that include that `Item`.

> If `REPOSITION` mode is true at the time of a `FILL`, either because the keyword is part of the definition or because you have set the attribute to true, then Progress ignores the Data-Relation that would otherwise filter the children to retrieve only those related to a parent of the relation, and fills the table as a top-level table.

> ##### Example with REPOSITION not set

> For example, consider an `Order` ProDataSet with a Data-Relation from `ttOrderLine` to `ttItem`, with relation fields of `ttOrderline.ItemNum` and `ttItem.ItemNum`. If you do not define or set the `REPOSITION` attribute, then Progress loads into `ttItem` the `Item` information for every `Item` used in at least one `OrderLine` that is also loaded into the ProDataSet. There might well be multiple `OrderLines` that use the same `Order`, but because the default fill processing is to discard records with duplicate keys, Progress automatically discards all duplicates based on the unique index definition for the `ttItem` temp-table, and you wind up with exactly one instance of each `Item` used on the ProDataSet’s `OrderLines`. If there is no unique index on the `ttItem` temp-table, then you wind up with one instance of `ttItem` for each `OrderLine` that uses a given `Item`, which is almost certainly not what you want.

> ##### Example with REPOSITION set: loading

> Alternatively, if you define or set the `REPOSITION` attribute of the relation, when Progress fills the ProDataSet, it disregards the relation fields of that Data-Relation and fills that table independent of its parent. This means that by default Progress loads all records from the child table’s database buffer into the temp-table. Or if you have prepared a specific query for the child table’s Data-Source, then the records that satisfy the query are loaded.

> Using the same example for `OrderLines` and their `Items`, with `REPOSITION` set to true, Progress loads all `Items` into `ttItem` regardless of whether they are used by `OrderLines` in this instance of the ProDataSet. This makes the entire list of `Items` available for display and selection in the user interface, or within business logic that uses the ProDataSet. You can set `REPOSITION` true or false for this type of relation, depending on your application requirements.

> ##### Example with REPOSITION set: navigation

> During navigation, `REPOSITION` mode serves a somewhat different purpose. As you learned in the introduction, Progress generates a dynamic query for each child table of a Data-Relation that you can use to browse the current records at that level, where the meaning of “current” is normally the set of children for the currently selected parent. If `REPOSITION` is true when your application is navigating the ProDataSet, then the query works differently. The query does not filter children, but selects all rows in the child table regardless of the parent. However, the child query is repositioned to the child row for the currently selected parent.

> Once again using the same example, if your user interface uses browse objects to show `OrderLines` of the current `Order` in one browse and `Items` in another browse, then with `REPOSITION` `False`, the `Item` browse will show only the one `ttItem` row for the current `ttOrderLine`. With `REPOSITION` `True`, the `ttItem` browse displays all `Items` and repositions to the `Item` for the current `OrderLine`. This `REPOSITION` mode has no other effect when you are navigating the ProDataSet. Again, set `REPOSITION` to `True` or `False` for this kind of many-to-one relationship, depending on which default behavior you want.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095