Re: Triggers

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Triggers
Date: 2005-11-22 16:25:50
Message-ID: Pine.LNX.4.44.0511221825001.24697-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

O Leif B. Kristensen έγραψε στις Nov 22, 2005 :

> I'm trying to understand triggers. I have read the documentation in the
> manual as well as the few pages in the Douglas book about the subject,
> but I don't see how to implement a trigger that simply updates a
> 'last_edit' date field in my 'persons' table whenever I do an insert or
> update into my 'participants' table; that is a trigger that basically
> does an "UPDATE persons SET 'last_edit' = NOW() WHERE persons.person_id
> = participants.person_fk". Is that even possible?
>

smth like:
foodb=# CREATE or REPLACE FUNCTION upd_dad() RETURNS "trigger" AS '
foodb'# BEGIN
foodb'# UPDATE dad set lastedit=now() where id=new.dadid;
foodb'# RETURN new;
foodb'# END;
foodb'# '
foodb-# LANGUAGE plpgsql;
CREATE FUNCTION
foodb=# CREATE TRIGGER upd_dad_tg AFTER INSERT OR UPDATE ON kid FOR EACH
ROW EXECUTE PROCEDURE upd_dad();

--
-Achilleus

In response to

  • Triggers at 2005-11-22 14:43:47 from Leif B. Kristensen

Responses

  • Re: Triggers at 2005-11-22 15:44:35 from Leif B. Kristensen

Browse pgsql-sql by date

  From Date Subject
Next Message John McCawley 2005-11-22 16:27:23 Re: deferrable on unique
Previous Message Neil Saunders 2005-11-22 16:21:38 Re: Triggers