Re: column: on update update?

From: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
To: "Michael Monnerie" <michael(dot)monnerie(at)it-management(dot)at>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: column: on update update?
Date: 2008-05-07 13:23:04
Message-ID: 396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, May 7, 2008 at 1:50 AM, Michael Monnerie
<michael(dot)monnerie(at)it-management(dot)at> wrote:
> But I also need the "lastupdate" be updated every time a field in that
> row is updated, so a statement like this:
>
> But it doesn't work. Do I need a trigger? If yes, what would be the
> format? I never did triggers.

Well you have two options. The perferred method would be to have your
application include an update to your lastupdate field whenever
anyother rows are updated.

UPDATE awl
SET lastupdate = CURRENT_TIMESTAMP,
....,
WHERE ....;

the other option is to add an after update trigger, and manually set
lastupdate then.

--
Regards,
Richard Broersma Jr.

Visit the Los Angles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2008-05-07 14:32:54 Re: duplicate primary index in bayes db from SpamAssassin
Previous Message Michael Monnerie 2008-05-07 09:03:53 Re: duplicate primary index in bayes db from SpamAssassin