help me on a trigger

Started by Pedroalmost 20 years ago2 messagesgeneral
Jump to latest
#1Pedro
pedro100@gmail.com

I need to create a trigger that decreases on a "stocks" table the amount
that have been inserted on the "tooken_from_stock" table.

the trigger should be something like:

CREATE TRIGGER triggerdecrease
BEFORE INSERT ON tooken_from_stock
EXECUTE PROCEDURE decrease();

then i need to create the procedure decrease that gets the inserted
"tooken_from_stock.amount" and subtracts it on "stocks.amount"

can anybody help me with this please?

thanks in advance.

#2Terry Lee Tucker
terry@esc1.com
In reply to: Pedro (#1)
Re: help me on a trigger

On Friday 02 June 2006 02:09 am, Pedro <pedro100@gmail.com> thus communicated:
--> I need to create a trigger that decreases on a "stocks" table the amount
--> that have been inserted on the "tooken_from_stock" table.
-->
--> the trigger should be something like:
-->
--> CREATE TRIGGER triggerdecrease
--> BEFORE INSERT ON tooken_from_stock
--> EXECUTE PROCEDURE decrease();
-->
-->
--> then i need to create the procedure decrease that gets the inserted
--> "tooken_from_stock.amount" and subtracts it on "stocks.amount"
-->
--> can anybody help me with this please?
-->
--> thanks in advance.
-->
See the documentation at the link below for a discussion on writting triggers.
http://www.postgresql.org/docs/8.1/static/plpgsql-trigger.html