Обсуждение: No date = bad date?

Поиск
Список
Период
Сортировка

No date = bad date?

От
Lynna Landstreet
Дата:
Hello all,

I've run into the old "bad date external representation" problem again, but
this time it's due to the date field in question in the text file I'm trying
to \copy into a table being empty. And, no, it's not set to "not null",
which so far as I'm aware would generate a different error message anyway.

Does anyone know of some reason why importing a text file that contains no
data for one date field would cause psql to tell me:

ERROR:  copy: line 1, Bad date external representation ''
lost synchronization with server, resetting connection

The field contents are *not* single quoted, but they weren't on the previous
text file that I was able to import successfully either.


Lynna
--
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org


Re: No date = bad date?

От
Josh Berkus
Дата:
Lynna,

> Does anyone know of some reason why importing a text file that contains no
> data for one date field would cause psql to tell me:
>
> ERROR:  copy: line 1, Bad date external representation ''
> lost synchronization with server, resetting connection

Yes.  For the "blank" date, you need to have an \N marker to indicate a NULL.
Or you need to change your copy parameters to indicate that a zero length
string is a NULL; check the COPY docs for details.

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


Re: No date = bad date?

От
Lynna Landstreet
Дата:
on 6/26/03 4:26 PM, Josh Berkus at josh@agliodbs.com wrote:

>> Does anyone know of some reason why importing a text file that contains no
>> data for one date field would cause psql to tell me:
>>
>> ERROR:  copy: line 1, Bad date external representation ''
>> lost synchronization with server, resetting connection
>
> Yes.  For the "blank" date, you need to have an \N marker to indicate a NULL.
> Or you need to change your copy parameters to indicate that a zero length
> string is a NULL; check the COPY docs for details.

Thanks - I added "with null as ''" and it worked fine.


Lynna
--
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org