automatic time/user stamp - rule or trigger?

From: Neal Lindsay <neal(dot)lindsay(at)peaofohio(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: automatic time/user stamp - rule or trigger?
Date: 2003-02-05 14:47:34
Message-ID: b1r864$2mpp$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a table that I want to keep track of the user who last modified
it and the timestamp of the modification. Should I use a trigger or a rule?

CREATE TABLE stampedtable (
stampedtableid SERIAL PRIMARY KEY,
updatestamp timestamp NOT NULL DEFAULT now(),
updateuser name NOT NULL DEFAULT current_user,
sometext text
);

I suspect that I want a rule, but all the examples in the documentation
seem to update a separate table and not override (or add) the
insert/update to the timestamp and name columns.

Thanks,
-Neal

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-02-05 15:23:18 Re: Problem with VACUUM
Previous Message Christoph Haller 2003-02-05 14:07:21 Re: Inserting a tab character