From: | "Alaric B(dot) Snell" <abs(at)frontwire(dot)com> |
---|---|
To: | will trillich <will(at)serensoft(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: caching subtotals: update vs sum -- aaugh! |
Date: | 2002-01-10 12:51:47 |
Message-ID: | Pine.LNX.4.43.0201101247430.32663-100000@calvin.frontwire.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 10 Jan 2002, will trillich wrote:
> or should i settle for something like
>
> select
> item_id,
> sum(bal) as bal,
> sum(cost) as cost,
> sum(charge) as charge
> into
> fooey
> from
> line_item
> group by
> item_id
> ;
> update invoice set
> bal = fooey.bal,
> cost = fooey.cost,
> charge = fooey.charge
> where fooey.item_id = id
> ;
> drop table fooey
> ;
>
> ...? seems a bit of the old "long-way-around"... surely there's
> a way--
A stored procedure sounds the way ahead to me. DO it with a trigger if you
want updates to happen automagically whenever the line_items are changed:
http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html
http://www.postgresql.org/idocs/index.php?sql-createtrigger.html
--
Alaric B. Snell, Developer
abs(at)frontwire(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Jochem van Dieten | 2002-01-10 13:00:23 | Re: select few fields as a single field |
Previous Message | Alaric B. Snell | 2002-01-10 12:46:47 | Re: Performance tips |