pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Neal Lindsay <neal.lindsay@peaofohio.com>
To: pgsql-sql@postgresql.org
Subject: automatic time/user stamp - rule or trigger?
Date: Wed, 05 Feb 2003 09:47:34 -0500
Message-ID: <b1r864$2mpp$1@news.hub.org> (raw)

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




view thread (6+ messages)  latest in thread

Message-ID: <b1r864$2mpp$1@news.hub.org>
Permalink:  ../b1r864$2mpp$1@news.hub.org/
Also on:    postgresql.org/message-id/b1r864$2mpp$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: neal.lindsay@peaofohio.com
  Subject: Re: automatic time/user stamp - rule or trigger?
  In-Reply-To: <b1r864$2mpp$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox