automatic timestamp question

From: Richard Seymour <rseymour(at)anarchysoftware(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: automatic timestamp question
Date: 2001-01-11 01:20:26
Message-ID: 3A5D0A5A.5C951BDB@anarchysoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table with a structure like:

CREATE TABLE xxx
(id int,
modified timestamp default current_timestamp,
created timestamp default current_timestamp,
something varchar(10));
somethingelse varchar(10));

What I want is for the modified field to automatically pop in the
current time whenever I update the record. The typical update would be
something like:

UPDATE xxx SET
something = "hello",
somethingelse = "goodbye" where id = 2;

What is the easiest, most generic way to do this?

In MySQL the first timestamp field (by default) automatically does this.

In PostgreSQL 7.0.3:
do I have to explicitly set the modified date?
do I have to create a stored procedure/trigger of some sort,?
or can I otherwise define behaviour that automatically happens
whenever the record is updated?

Thanks.

--
Richard Seymour : Anarchy Software, Inc.
- * - - * - - - * -+- * - - - * - - * -
`°º¤ø,¸ ¸,ø¤º°'
`°º¤ø,¸¸,ø¤º°

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lloyd Llewellyn 2001-01-11 01:40:26 PGAccess (or other GUI) RPM?
Previous Message Craig L. Ching 2001-01-11 00:49:34 RE: [HACKERS] Re: still no log