Re: update in rule

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Radoslaw Stachowiak <radek(at)alter(dot)pl>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: update in rule
Date: 2001-11-07 17:07:49
Message-ID: 20011107090403.K49204-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

On Wed, 7 Nov 2001, Radoslaw Stachowiak wrote:

> *** Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> [Wednesday, 17.October.2001, 12:04 -0700]:
> > create function adresses_trigger() returns opaque as '
> > begin
> > NEW.date_maj := now();
> > return NEW;
> > end;' language 'plpgsql';
> > create trigger tr before update on adresses for each row execute
> > procedure adresses_trigger();
>
> why sould I use before (instead of after)?
> isnt it a little dangerous in transactions? /hope not/
>
> I know difference between both forms. The question is rather about if
> timestamp updating shouldnt be run AFTER update which I think is closer
> to a real world situations (of course evth vary). But maybe there are
> some probles with after, which I dont know about?

It's pretty much 6 of one, half dozen of another AFAICS. This doesn't
actually update the table per-se, it updates the copy of the row that
you've asked to update the row to. The actual update changes the date
column.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Nick Sayer 2001-11-07 17:50:01 Re: Problems with user-level security
Previous Message Stephan Szabo 2001-11-07 17:03:52 Re: Problems with user-level security

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-11-07 17:14:19 Re: Need help with embedded CASEs
Previous Message John D. Rozeboom 2001-11-07 16:53:55 Re: Need help with embedded CASEs