Re: [GENERAL] Best way to allow column to initially be null?

Поиск
Список
Период
Сортировка
От Berend Tober
Тема Re: [GENERAL] Best way to allow column to initially be null?
Дата
Msg-id ede5288f-77d6-8359-8f93-97b69c8841c7@computer.org
обсуждение исходный текст
Ответ на [GENERAL] Best way to allow column to initially be null?  (Glen Huang <heyhgl@gmail.com>)
Ответы Re: [GENERAL] Best way to allow column to initially be null?  (Glen Huang <heyhgl@gmail.com>)
Список pgsql-general
Glen Huang wrote:> I’m trying to make a column have these properties:>> 1. When a row is inserted, this column is
allowedto be null. 2. When the row is updated, no null> can be assigned to it this column.>> I initially thought I can
dropthe not null constraint before insertion and turn it back on after> that, but after reading the doc it seems
turningon not null constraint requires not columns> contain null value, so looks like it won’t work.>> My current
approachis to not set the not null constraint in the table and use a before update> trigger to manually raise exception
whenthe column is null. But it doesn’t seem as elegant.>> Is there a better way?>
 

Sounds to me like a BEFORE UPDATE trigger is exactly the way to handle this. Rejecting invalid data 
input values is an ideal use case for such a facility.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

В списке pgsql-general по дате отправления:

Предыдущее
От: Glen Huang
Дата:
Сообщение: [GENERAL] Best way to allow column to initially be null?
Следующее
От: Glen Huang
Дата:
Сообщение: Re: [GENERAL] Best way to allow column to initially be null?