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$77de010a@billshaw.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> Greetings all, i've been reading your postings awhiles now and have come
from
> 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
soon
> enough for a charity project i'm doing, can anyone give some pointers on
what
> 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
rows.
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
rows
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 @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Frank Bax 2002-01-24 12:50:58 Re: Disk I/O
Previous Message denis 2002-01-24 05:57:34 Disk I/O