protecting a field after creation
protecting a field after creation
От:
Louis-David Mitterrand <cunctator@apartia.ch>
Дата:
Hello, 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. Thanks in advance, -- Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org Murphy's Guide to Science: If it's green or squirms, it's biology. If it stinks, it's chemistry. If it doesn't work, it's physics.
Re: protecting a field after creation
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Louis-David Mitterrand 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