NULL becomes default

Поиск
Список
Период
Сортировка
От Julian Scarfe
Тема NULL becomes default
Дата
Msg-id 029c01c6c228$8e8e5210$0600a8c0@Wilbur
обсуждение исходный текст
Ответы Re: NULL becomes default  (Sumeet <asumeet@gmail.com>)
Re: NULL becomes default  (Markus Schaber <schabi@logix-tt.com>)
Список pgsql-sql
A surrogate key has been introduced on a table with modifiers:
  Column    |            Type             | 
Modifiers
-------------+-----------------------------+------------------------------------------------------------new_id    |
integer                    | not null default 
 
nextval(('some_id_seq'::text)::regclass)

However, some legacy software inserts into the table by first getting column 
names and then composing an INSERT for all the columns, filling in any 
undefined values with NULLs.

Thus when it attempts to insert a row I get a:

ERROR:  null value in column "new_id" violates not-null constraint

Thus I would like NULLs in such INSERTs to be treated as DEFAULT rather than 
violating the constraint.  Is there an easy way to do that at the database 
level?

Thanks

Julian




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

Предыдущее
От: MaXX
Дата:
Сообщение: Re: Help with optional parameters
Следующее
От: Sumeet
Дата:
Сообщение: Re: NULL becomes default