trigger/cached updates question - Mailing list pgsql-general

From Ashley Clark
Subject trigger/cached updates question
Date
Msg-id 20001020232414.A32584@ghoti.org
Whole thread Raw
List pgsql-general
I've got a project where I have two tables that are linked together on
an inventory code. Big deal. There is the inventory table, containing
qty_onhand and qty_onorder. Then there is the order_items table,
containing inven_code and qty. I have the inven_code in the order_items
table set to cascade on update of inventory and I have a trigger that
on insert/update/delete to order_items the inventory tables qty_onhand
and qty_onorder values are updated appropriately.

This is a pain in the ass.

Because if the inventory code changes then order_items() is called, it
all works brilliantly but I can't keep helping to think that maybe
there's an easier way. Am I just amusing myself by thinking that? I've
wracked my brains but I can't seem to figure out a way around the
qty_onorder field, could I use a view somehow for that? But, I have to
be able to find items in that same list where there are no parts on
order (left outer-join). Anyway I've attached the function I've written
so maybe anyone who is interested can give me pointers, use it
themselves instead of taking the time it took me to figure out PLpgsql,
or tell me I'm braindead because there is a *much* easier way to do
this.

Thanks

--
creaky halls

Attachment

pgsql-general by date:

Previous
From: Sungchul Park
Date:
Subject: duplicate key ? (fwd)
Next
From: KuroiNeko
Date:
Subject: Re: duplicate key ? (fwd)