X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id ABBC4310CEE for ; Tue, 1 Jul 2003 20:03:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 16928-04 for ; Tue, 1 Jul 2003 17:03:13 -0300 (ADT) Received: from www.postgresql.com (www.postgresql.com [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id C99D7310D35 for ; Tue, 1 Jul 2003 17:02:47 -0300 (ADT) Received: from localhost.localdomain (unknown [65.217.53.66]) by www.postgresql.com (Postfix) with ESMTP id 771B5CF6CF1 for ; Tue, 1 Jul 2003 13:29:31 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h61HQR4i018479; Tue, 1 Jul 2003 13:26:27 -0400 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h61GSRZ17725; Tue, 1 Jul 2003 12:28:28 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id MTKBP43Z; Tue, 1 Jul 2003 12:28:25 -0400 Subject: Re: Immutable attributes? From: Robert Treat To: Troels Arvin Cc: pgsql-sql@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 01 Jul 2003 12:28:27 -0400 Message-Id: <1057076907.11365.411.camel@camel> Mime-Version: 1.0 X-Archive-Number: 200307/17 X-Sequence-Number: 14131 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