Re: Null vs empty string

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Null vs empty string
Дата
Msg-id 20041204032756.GB55376@winnie.fuhr.org
обсуждение исходный текст
Ответ на Null vs empty string  ("Keith Worthington" <keithw@narrowpathinc.com>)
Ответы Re: Null vs empty string  ("Keith Worthington" <keithw@narrowpathinc.com>)
Список pgsql-novice
On Fri, Dec 03, 2004 at 08:57:24PM -0500, Keith Worthington wrote:

> I am loading data into a PostgreSQL v7.3.6 database running on RedHat
> Enterprise Linux ES.  This is accomplished by a shell script running the COPY
> command.  The data is in comma seperated value format.
>
> I am experiencing two difficulties.
>
> Firstly, when loading a missing (consecutive commas) numeric value (int4) an
> error message is generated indicating that the string cannot be parsed.  I
> would prefer that a NULL value be inserted.
>
> Secondly, when loading a missing (consecutive commas) string (varchar) an
> empty string is inserted.  Again, I would prefer that a NULL value be inserted
> as later on a foreign key constraint complains bitterly about not being able
> to match the empty string. :-(

Have you tried using NULL AS?

COPY foo FROM stdin WITH DELIMITER ',' NULL AS '';

Would that break anything else for you?  An alternative would be
to replace the empty fields in your data with \N, the default string
that represents NULL.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: multiple table join and sumation
Следующее
От: "Keith Worthington"
Дата:
Сообщение: Re: Null vs empty string