Building Parameterized Hierarchies
Important
This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Instead, applications should use XML.
The Data Shaping Service for OLE DB can be used to create a relationship between two rowsets retrieved from parent and child tables. The relationship of the child rows to the parent is based on parameters set in the SHAPE command. The hierarchical outcome of a parameter-based hierarchy has the same structure as when relating a parent row to a child row using RELATE <parent row> TO <child row>. When the PARAMETER clause is used in a RELATE statement, the hierarchy is considered to be parameter-based. Hybrid RELATE statements, where the RELATE clause contains both parent column to child column and parent column to child provider command parameters, are supported.
Building a parameter-based hierarchy requires an active connection so that as you move to new parent rows, the child rows, as specified by the parameters, can be fetched. This type of rowset is useful when fetching only a few chapters.
After the connection is made and the SHAPE command invoked, the parent rows are fetched in their entirety. As you navigate through the fetched parent rows, the child query is executed anew to fetch the appropriate child rows. The parameter values used to execute the child query are taken from the specified columns in the parent row.
Using the following example of retrieving data from the Customers and Orders tables in the Sales database, the entire Customers table is loaded into a rowset. Each chapter in the child rowset (rsOrders) is fetched by executing the child query with the appropriate parameter. The child query for a specific chapter is not executed until the child rows are actually requested.
SHAPE {select * from Customers}
APPEND ({select * from Orders where cust_id = ?}
AS rsOrders
RELATE cust_id TO PARAMETER 0)
AS ChpOrders
This results in the following hierarchy, which is the same as a relation-based hierarchy:
See Also
Reference
Lifetime of Row Handles Within Chapters