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

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 (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-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

pgsql-admin by date

Next:From: Nick SayerDate: 2001-11-07 17:50:01
Subject: Re: Problems with user-level security
Previous:From: Stephan SzaboDate: 2001-11-07 17:03:52
Subject: Re: Problems with user-level security

pgsql-sql by date

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

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