|
1 | 1 | <!-- |
2 | | -$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.56 2005/01/14 01:16:22 tgl Exp $ |
| 2 | +$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.57 2005/01/15 03:38:44 tgl Exp $ |
3 | 3 | --> |
4 | 4 |
|
5 | 5 | <chapter id="plpgsql"> |
@@ -2787,17 +2787,12 @@ CREATE OR REPLACE FUNCTION maint_sales_summary_bytime() RETURNS TRIGGER AS $main |
2787 | 2787 | amount_sold, |
2788 | 2788 | units_sold, |
2789 | 2789 | amount_cost) |
2790 | | - SELECT f.time_key, |
2791 | | - sum(f.amount_sold), |
2792 | | - sum(f.units_sold), |
2793 | | - sum(f.amount_cost) |
2794 | | - FROM sales_fact f |
2795 | | - WHERE f.time_key = delta_time_key |
2796 | | - GROUP BY f.time_key; |
2797 | | - -- This query can potentially be very expensive if the trigger |
2798 | | - -- is created on sales_fact without the time_key indexes. |
2799 | | - -- Some care is needed to ensure that this situation does |
2800 | | - -- *not* occur. |
| 2790 | + VALUES ( |
| 2791 | + delta_time_key, |
| 2792 | + delta_amount_sold, |
| 2793 | + delta_units_sold, |
| 2794 | + delta_amount_cost |
| 2795 | + ); |
2801 | 2796 | EXCEPTION |
2802 | 2797 | -- |
2803 | 2798 | -- Catch race condition when two transactions are adding data |
|