X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1F9C1DB080 for ; Tue, 22 Nov 2005 13:17:32 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78363-09 for ; Tue, 22 Nov 2005 17:17:30 +0000 (GMT) X-Greylist: delayed 01:20:29.990407 by SQLgrey- Received: from mail44.e.nsc.no (mail44.e.nsc.no [193.213.115.44]) by svr1.postgresql.org (Postfix) with ESMTP id BB99CDB069 for ; Tue, 22 Nov 2005 13:17:26 -0400 (AST) Received: from [192.168.0.57] (062016183238.customer.alfanett.no [62.16.183.238]) (authenticated bits=0) by mail44.nsc.no (8.13.5/8.13.5) with ESMTP id jAMHHNOX004997 for ; Tue, 22 Nov 2005 18:17:24 +0100 (CET) From: "Leif B. Kristensen" To: "Pgsql-sql@postgresql.org" Subject: Re: Triggers User-Agent: KMail/1.8.1 References: In-Reply-To: X-Face: %iea8o"[SI'kMDS.`hz7lU=?\^lC9J-]CVjo; f{4-C:$?uVUEjyN~uYFn%*aH_c3d09U>=?iso-8859-1?q?x=0A=09TXtaoj=7EMV=2E8PgG7hik9=3BcCT2N6+u?=@Y{wH\p3*_f~FH9k,Wi74e[_l%.7b^'zJ)8S'^G<(=?iso-8859-1?q?=3D=0A=09zw8=5CPMC3=27=7BKl9=2EzL*ks!b6wA?=,c~'F`k&Vq|ELDGa|4 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[AWL=-0.001, HTML_MESSAGE=0.001, UPPERCASE_25_50=0] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200511/206 X-Sequence-Number: 23457 --Boundary-00=_jK1gDVgXeDK78ng Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: 7bit On Tuesday 22 November 2005 18:07, Achilleus Mantzios wrote: >O Leif B. Kristensen ?????? ???? Nov 22, 2005 : >> What am I missing? > >apparently some forgotten process_last_edited() function. Yes -- an earlier attempt at the same thing ... I finally managed to create my first trigger: CREATE OR REPLACE FUNCTION update_last_edit() RETURNS TRIGGER AS $$ BEGIN UPDATE persons SET last_edit=NOW() WHERE person_id=NEW.person_fk; RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER update_last_edit BEFORE INSERT OR UPDATE ON participants FOR EACH ROW EXECUTE PROCEDURE update_last_edit(); And it's even working as it should :-) Thanks, guys. -- Leif Biberg Kristensen | Registered Linux User #338009 http://solumslekt.org/ | Cruising with Gentoo/KDE --Boundary-00=_jK1gDVgXeDK78ng Content-Type: text/html; charset="iso-8859-7" Content-Transfer-Encoding: 7bit

On Tuesday 22 November 2005 18:07, Achilleus Mantzios wrote:

>O Leif B. Kristensen ?????? ???? Nov 22, 2005 :

>> What am I missing?

>

>apparently some forgotten process_last_edited() function.

Yes -- an earlier attempt at the same thing ...

I finally managed to create my first trigger:

CREATE OR REPLACE FUNCTION update_last_edit() RETURNS TRIGGER AS $$

BEGIN

UPDATE persons SET last_edit=NOW() WHERE person_id=NEW.person_fk;

RETURN NEW;

END;

$$ LANGUAGE plpgsql;

CREATE TRIGGER update_last_edit

BEFORE INSERT OR UPDATE ON participants

FOR EACH ROW EXECUTE PROCEDURE update_last_edit();

And it's even working as it should :-)

Thanks, guys.

--

Leif Biberg Kristensen | Registered Linux User #338009

http://solumslekt.org/ | Cruising with Gentoo/KDE

--Boundary-00=_jK1gDVgXeDK78ng--