You want a trigger. Similar to the following:
CREATE FUNCTION "netblock_date_change" () RETURNS opaque AS 'DECLARE BEGIN new.last_update_at = cast(now() as
timestamp(0)); new.last_update_by = current_user; return new; END;' LANGUAGE 'plpgsql';
CREATE TRIGGER "netblock_change" BEFORE INSERT OR UPDATE ON "networks" FOR
EACHROW EXECUTE PROCEDURE "netblock_date_change" ();
--On Wednesday, February 12, 2003 09:46:15 +0100 Daniel Jaenecke
<daniel.jaenecke@smaxs.de> wrote:
> Hi!
>
> I am rather new to PostGreSQL, having mainly used MySQL until now.
> MySQL has a column type TIMESTAMP[1] which holds - as expected - a
> timestamp, but additionally this timestamp is being updated automatically
> on any UPDATE or INSERT operation.
>
> Since this is a quite handy feature to keep track of latest changes I
> would like to create such a behavior for my PostGres tables too. But
> since I have no idea how to do it I would warml welcome any suggestion...
> :)
>
> Thx
> dj
>
> [1]
> http://www.mysql.com/doc/en/DATETIME.html
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749