Re: a rule question - Mailing list pgsql-novice

From Ludwig Lim
Subject Re: a rule question
Date
Msg-id 20021023160532.89482.qmail@web80310.mail.yahoo.com
Whole thread Raw
In response to a rule question  (Brad Paul <bpaul@carolina.rr.com>)
List pgsql-novice
--- Brad Paul <bpaul@carolina.rr.com> wrote:
> I have also tried:
>
> create rule inventory_usage_insert_rule as
>        on insert to inventory_usage
>        do
>     update inventory set
> new.in_stock=old.in_stock-inventory_usage.used
>            where
> inventory.inventory_id=inventory_usage.inventory_id;
>

 Try recoding it as :

  CREATE RULE inventory_usage_insert_rule AS
     ON INSERT TO inventory_usage
     DO
        UPDATE inventory
        SET in_stock = in_stock - NEW.used
        WHERE inventory.inventory_id =
NEW.inventory_id;

Hope this helps,

ludwig.


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

pgsql-novice by date:

Previous
From: Ludwig Lim
Date:
Subject: Re: Display SELECT
Next
From: "Devinder K Rajput"
Date:
Subject: Re: Display SELECT