Re: automatic time/user stamp - rule or trigger?

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Neal Lindsay <neal(dot)lindsay(at)peaofohio(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: automatic time/user stamp - rule or trigger?
Date: 2003-02-05 19:48:30
Message-ID: Pine.LNX.4.44.0302051745400.7803-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 5 Feb 2003, Neal Lindsay wrote:

> 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.

You may want to use rules if you need rewriting.
What you actually need is some sort of driver to a specific table.
You could create a view to that table (to hide the accounting columns),
and then create rules on that view that do the job as you wish.

>
> Thanks,
> -Neal
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel: +30-10-8981112
fax: +30-10-8981877
email: achill(at)matrix(dot)gatewaynet(dot)com
mantzios(at)softlab(dot)ece(dot)ntua(dot)gr

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message codeWarrior 2003-02-05 23:38:52 Re: automatic time/user stamp - rule or trigger?
Previous Message Neal Lindsay 2003-02-05 19:33:29 Re: automatic time/user stamp - rule or trigger?