Re: protecting a field after creation - Mailing list pgsql-sql

From Tom Lane
Subject Re: protecting a field after creation
Date
Msg-id 10467.966792684@sss.pgh.pa.us
Whole thread Raw
In response to protecting a field after creation  (Louis-David Mitterrand <cunctator@apartia.ch>)
List pgsql-sql
Louis-David Mitterrand <cunctator@apartia.ch> writes:
> Is there a way (outside of RULEs and  TRIGGERs) to make a field
> read-only once it is INSERTed or assigned its default value? I'm
> thinking, for example, of the "created" column that I add to most
> tables, holding the row's creation timestamp.

An on-update trigger seems like a very simple solution here.
You could either copy the old value into the new, or raise an
error if they are different, depending on what you want.
        regards, tom lane


pgsql-sql by date:

Previous
From: Louis-David Mitterrand
Date:
Subject: protecting a field after creation
Next
From: The Hermit Hacker
Date:
Subject: Re: Speed or configuration