pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Treat <xzilla@users.sourceforge.net>
To: Troels Arvin <troels@arvin.dk>
Cc: pgsql-sql@postgresql.org
Subject: Re: Immutable attributes?
Date: 01 Jul 2003 12:28:27 -0400
Message-ID: <1057076907.11365.411.camel@camel> (raw)
In-Reply-To: <pan.2003.07.01.09.59.23.580853@arvin.dk>
References: <pan.2003.07.01.09.59.23.580853@arvin.dk>

On Tue, 2003-07-01 at 05:59, Troels Arvin wrote:
> Hello,
> 
> I have a table like this:
> 
> create table test (
>   "test_id" serial primary key,
>   "created" timestamp with time zone
>      default current_timestamp
>      check(created = current_timestamp),
>   "some_datum" int not null
> );
> 
> My question concerns the "created" attribute: I want this to reflect when
> the tuple was craeated; and I want to make sure that the timestamp is not
> wrong. That will work with the above schema. However, I also want to make
> sure that the "crated" attribut for a tuple is not changed once it has
> been set.
> 
> I'm thinking about implementing it through a trigger, but is there a
> better way to create such "immutable" attributes?
> 

I don't know if it's "better", but this is one of the things people find
the RULE system really handy for. Check the docs, I believe there are
examples of this.

Robert Treat 
-- 
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL




view thread (3+ messages)  latest in thread

Message-ID: <1057076907.11365.411.camel@camel>
Permalink:  ../1057076907.11365.411.camel@camel/
Also on:    postgresql.org/message-id/1057076907.11365.411.camel@camel

 · 

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: xzilla@users.sourceforge.net, troels@arvin.dk
  Subject: Re: Immutable attributes?
  In-Reply-To: <1057076907.11365.411.camel@camel>

* 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