Re: Question about inserts

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Question about inserts
Дата
Msg-id 20040423140257.GC6182@wolff.to
обсуждение исходный текст
Ответ на Question about inserts  (mike <mike@redtux1.uklinux.net>)
Список pgsql-general
On Fri, Apr 23, 2004 at 11:36:51 +0100,
  mike <mike@redtux1.uklinux.net> wrote:
> Is it possible to to the following
>
> I have tables which are updated via webpage (perl) with fields of type
> int and date (all nullable). If the values are blank the entire insert
> fails, with a wrong type error.
>
> Is there any way to stop this behaviour so that the valid information is
> allowed,but the blank values get ignored.

Ignore? If you want blanks turned into NULLs, probably the best place to
do this is in the application. I can think of three ways to do this:

Use NULLIF to replace the specified input strings into NULLs, while
leaving other strings as is.

Have the appkication detect the strings that should be NULL and replace them
with NULL (which shouldn't be quoted unlike the normal string data).

Split off the two columns that can have null values into their own tables
and only enter records there when the input is nonblank. This is perhaps
the closest to "ignoring" blanks that you can do.

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

Предыдущее
От: "Stijn Vanroye"
Дата:
Сообщение: Re: Question about inserts
Следующее
От: "Bas Scheffers"
Дата:
Сообщение: Re: Insert Or update