trigger/cached updates question

From: Ashley Clark <aclark(at)ghoti(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: trigger/cached updates question
Date: 2000-10-21 04:24:15
Message-ID: 20001020232414.A32584@ghoti.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
inven.sql text/plain 2.0 KB

Browse pgsql-general by date

  From Date Subject
Next Message Sungchul Park 2000-10-21 04:25:58 duplicate key ? (fwd)
Previous Message Andrew Evans 2000-10-21 01:43:00 Re: MySQL -> pgsql