Received: from megazone.bigpanda.com ([63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA7H7im13585 for ; Wed, 7 Nov 2001 12:07:44 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 8373BD5DB; Wed, 7 Nov 2001 09:07:49 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 792235BDE; Wed, 7 Nov 2001 09:07:49 -0800 (PST) Date: Wed, 7 Nov 2001 09:07:49 -0800 (PST) From: Stephan Szabo To: Radoslaw Stachowiak Cc: Subject: Re: update in rule In-Reply-To: <20011107115249.V7681@blue.alter.pl> Message-ID: <20011107090403.K49204-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200111/26 X-Sequence-Number: 2551 On Wed, 7 Nov 2001, Radoslaw Stachowiak wrote: > *** Stephan Szabo [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.