pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Broersma <richard.broersma@gmail.com>
To: Michael Monnerie <michael.monnerie@it-management.at>
Cc: pgsql-admin@postgresql.org
Subject: Re: column: on update update?
Date: Wed, 7 May 2008 06:23:04 -0700
Message-ID: <396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com> (raw)
In-Reply-To: <200805071050.41450@zmi.at>
References: <200805071050.41450@zmi.at>

On Wed, May 7, 2008 at 1:50 AM, Michael Monnerie
<michael.monnerie@it-management.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



view thread (5+ messages)  latest in thread

Message-ID: <396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com>
Permalink:  ../396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com/
Also on:    postgresql.org/message-id/396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: richard.broersma@gmail.com, michael.monnerie@it-management.at
  Subject: Re: column: on update update?
  In-Reply-To: <396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox