Re: Update timestamp on update

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Williams <jeffw(at)globaldial(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Update timestamp on update
Date: 2005-10-13 01:44:49
Message-ID: 16305.1129167889@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-sql

Jeff Williams <jeffw(at)globaldial(dot)com> writes:
> last_status_change timestamp DEFAULT now()

> What I would like is that whenever the status is changed the
> last_status_change timestamp is updated to the current time.

For this you use an ON UPDATE trigger; rules are not a good way to solve
it. See the documentation about triggers. The first example on this
page does it along with a few other things:
http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html

regards, tom lane

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Jeff Williams 2005-10-13 02:42:06 Re: Update timestamp on update
Previous Message Jeff Williams 2005-10-13 01:12:34 Update timestamp on update

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Bax 2005-10-13 01:48:09 Re: SEVEN cross joins?!?!?
Previous Message Greg Stark 2005-10-13 01:13:29 Re: pg, mysql comparison with "group by" clause