Writing a Complex Shape Statement

In the previous section, you worked with a simple SHAPE statement that displayed order information for each customer in the Northwind database in the Immediate window. You learned how to nest a child recordset within a parent recordset and access the fields in both.

Creating and Manipulating Databases with ADO

In the following sections, you will learn how to write more complex SHAPE statements that include multiple child and grandchild recordsets.

Shaped Recordsets with Multiple Children

Data shaping does not limit you to having just one child recordset within a parent recordset. You can specify as many children as you want. For example, to display a parent with two children, use the following syntax:

SHAPE {SELECT * FROM Parent} APPEND ({SELECT * FROM Child1}

RELATE parent-column TO child1-column) AS child1-alias, ({SELECT * FROM Child2}

RELATE parent-column TO child2-column) AS child2-alias

Notice that additional children (siblings) are added to the end of the APPEND clause.

Suppose you want to display both the orders and products for a customer in the Northwind database. Using the syntax provided earlier, you can shape your hierarchical recordset as demonstrated in the ShapeMultiChildren procedure shown in Hands-On 16-5.

0 0

Post a comment