Re: creating a trigger to write to a different table

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Peter Choe <choepete(at)mindspring(dot)com>
Cc: postgres <pgsql-general(at)postgresql(dot)org>
Subject: Re: creating a trigger to write to a different table
Date: 2001-03-22 17:18:51
Message-ID: Pine.BSF.4.21.0103220909540.41849-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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();

In response to

Browse pgsql-general by date

  From Date Subject
Next Message The Hermit Hacker 2001-03-22 17:29:47 Re: Re: Call for platforms
Previous Message Jonas Bengtsson 2001-03-22 17:17:27 RE: OID as Primary Key