automatic timestamp question - Mailing list pgsql-general

From Richard Seymour
Subject automatic timestamp question
Date
Msg-id 3A5D0A5A.5C951BDB@anarchysoftware.com
Whole thread Raw
Responses Re: automatic timestamp question
List 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.
- * - - * - - - * -+- * - - - * - - * -
      `°º¤ø,¸             ¸,ø¤º°'
             `°º¤ø,¸¸,ø¤º°

pgsql-general by date:

Previous
From: "Craig L. Ching"
Date:
Subject: RE: [HACKERS] Re: still no log
Next
From: Ben Stringer
Date:
Subject: Casting money to numeric(10,2)