CHAPTER 12 – Databases OMRON
Page 214 Release 2.0
Compound Relation Hierarchy example:
This sample illustrates a three-level hierarchy of customers, orders, and order details:
SHAPE {SELECT * from customers}
APPEND ((SHAPE {select * from orders}
APPEND ({select * from [order details]} AS rsDetails
RELATE orderid TO orderid)) AS rsOrders
RELATE customerid TO customerid)
In addition to the Simple Relation Hierarchy example, the Order ID is now used to create a recordset
containing the order details for the shown order.
Hierarchy with Aggregate example:
SHAPE (select * from orders}
APPEND ({select od.orderid, od.UnitPrice * od.quantity as
ExtendedPrice
from [order details] As od}
RELATE orderid TO orderid) As rsDetails,
SUM(ExtendedPrice) AS OrderTotal
This example creates a Recordset of all the orders and their details, and adds a field called
ExtendedPrice to store the total order value for each record, and sums all the ExtendedPrice values
which is stored in Order Total.
Group Hierarchy example:
SHAPE {select customers.customerid AS cust_id, orders.*
from customers inner join orders on customers.customerid =
orders.customerid} AS rsOrders
COMPUTE rsOrders BY cust_id
Group Hierarchy with Aggregate example:
SHAPE
(SHAPE {select customers.*, orders.orderid, orders.orderdate from
customers inner join orders on customers.customerid =
orders.customerid}
APPEND ({select od.orderid,
od.unitprice * od.quantity as ExtendedPrice from [order details]
as od} AS rsDetails
RELATE orderid TO orderid),