Re: creating a trigger to write to a different table - Mailing list pgsql-general

From Stephan Szabo
Subject Re: creating a trigger to write to a different table
Date
Msg-id Pine.BSF.4.21.0103220909540.41849-100000@megazone23.bigpanda.com
Whole thread Raw
In response to creating a trigger to write to a different table  (Peter Choe <choepete@mindspring.com>)
List pgsql-general
On Thu, 22 Mar 2001, Peter Choe wrote:

> can i use pl/pgsql to write a trigger to update a separate table?

You should be able to.  You can use update, etc, from the trigger.

For example a simple summing one might be (not really tested)
create function summer() returns opaque
as '
begin;
 update table2 set val=val+NEW.val where id=NEW.id;
 return NEW;
end;
' language 'plpgsql';
)

create trigger tr after insert on table1 for each row execute
procedure summer();



pgsql-general by date:

Previous
From: "Jonas Bengtsson"
Date:
Subject: RE: OID as Primary Key
Next
From: "Richard Huxton"
Date:
Subject: Re: Foreign keys/unique values and views