forcing a literal value in a column

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: forcing a literal value in a column
Date: 2003-05-13 11:46:03
Message-ID: 20030513134603.P564@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

in my audit trail tables I want two columns to _always_ be
CURRENT_USER/CURRENT_TIMESTAMP.

I am currently doing this:
...
modified_by name not null default CURRENT_USER check(modified_by=CURRENT_USER),
...
(respective for CURRENT_TIMESTAMP)

I know this can also be achieved with a trigger on insert/update.
However, I'd like to know what is the "PostgreSQL way" of
doing this ? Do I achieve what I want with my above solution ?
It seems to work but feels clunky.

I am sure this has been discussed before on the mailing lists
but despite my search I have not been able to locate the
threads. Please point me to the keywords I need to use for the
search to succeed.

Thanks,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Wolfgang Kueter 2003-05-13 12:50:13 Re: Problem Starting Postgresql after upgrade from SuSE8.1 to SuSE 8.2
Previous Message Max Bernaert 2003-05-13 10:38:50 cygz.dll not found.