Now that order detail lines are being completely calculated, we wish to SUM the total of the order lines to the order total.
Calculating a SUM is as easy as a FETCH. The two types of automation both depend on a foreign key. Whereas the FETCH sends information 'down' from a parent table to a child table, a SUM adds information 'up' from child rows to a parent row.
Maintaining a sum of all of the order lines is as easy as adding an automated column to the header:
column order_num:
type_id: int
description: Order Number
table orders_h:
module: orders
description: Orders
column order_num:
uisearch: "Y"
primary_key: "Y"
automation_id: SEQUENCE
foreign_key customers:
uisearch: "Y"
column price_lines:
suffix: _lines
automation_id: SUM
auto_formula: orders_d.price_extended
In the next tutorial we will review what we have created so far, and from there we will go on to add a credit limit constraint to our system.