Skip site navigation (1) Skip section navigation (2)

Re: trigger envy

From: "Stephan Szabo" <acroyear_07030(at)yahoo(dot)com>
To: "cromwell" <cromwell(at)innocent(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: trigger envy
Date: 2002-01-24 06:29:15
Message-ID: 001501c1a4a0$731fefc0$ (view raw or whole thread)
Lists: pgsql-novice
> Greetings all, i've been reading your postings awhiles now and have come
> complete tyro to aprentice novice reading them :)  Its about time for me
to start
> cutting my teeth on something real, and i'll have to start doing triggers
> enough for a charity project i'm doing, can anyone give some pointers on
> events i can handle, how i can detect them, and what i can do once i have?

You can have triggers run before or after the insert, update or deletion of
The trigger will be run once per row affected by the SQL statement.

In before triggers you can modify the request being done.  For insert or
update this
allows you to change the row that is going to be placed into the database
(modify the
tuple you return at the end of the trigger).  For all three actions, you may
cancel the
action on that row (by returning NULL).  Before triggers are useful on
insert and update
for doing modifications like adding timestamp columns and such.

In after triggers you can run things that want to see the state of the
database after
the statement action has occurred (like the row has been inserted, affected
have been updated, etc...). Our current foreign key support is a special
form of
after triggers as an example of things that can be done.

Do You Yahoo!?
Get your free address at

In response to

pgsql-novice by date

Next:From: Frank BaxDate: 2002-01-24 12:50:58
Subject: Re: Disk I/O
Previous:From: denisDate: 2002-01-24 05:57:34
Subject: Disk I/O

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group