Re: Can't copy empty value to datatype 'timestamp'

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jon Thorson <oinos(at)darkgeek(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Can't copy empty value to datatype 'timestamp'
Date: 2003-01-09 06:59:02
Message-ID: 20030108225355.M87384-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 9 Jan 2003, Jon Thorson wrote:

> I'm running into a problem importing data into my database. What seems
> to be the issue is an empty value on a field defined as 'timestamp'. In
> psql I'm using the following command to import the data:
>
> copy devicem1 from '/data/tmp/scshadow/devicem1.out' delimiter '|';
>
> I get the following error:
>
> ERROR: copy: line 1, Bad timestamp external representation ''
>
> There are 109 fields in this table, four fields with the datatype of
> 'timestamp'. The data that I am trying to import has the first two of
> the timestamp fields populated, and the last two are for future use.
> The definition for each timestamp field is simply:
>
> "<field name>" timestamp,
>
> I've tried specifically allowing null values to the fields, but I still
> get the same error. I would include a sample row but it's rather long
> and it would get mangled with the word wrap of my email client. Suffice
> it to say that the data is pipe delimited and the fields that are empty
> look like "||" (minus the double quotes, of course).

By default empty string is not null for copying (since you might want to
insert an empty text string, etc). You can change the sequence that is
considered null into an empty string however,
copy ... delimiter '|' null '';

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jon Thorson 2003-01-09 07:10:08 Re: Can't copy empty value to datatype 'timestamp'
Previous Message Shridhar Daithankar 2003-01-09 06:56:28 Re: Can't copy empty value to datatype 'timestamp'