pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bad Timestamp Error with COPY
2+ messages / 2 participants
[nested] [flat]

* Bad Timestamp Error with COPY
@ 2004-11-10 21:40  Sharon Schooley <schooleys@co.kern.ca.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Sharon Schooley @ 2004-11-10 21:40 UTC (permalink / raw)
  To: pgsql-admin

I am new to Postgresql. I'm trying to load tables from SQLServer bcp export, comma delimited.  I'm loading datetime datatype into timestamp. I've loaded one table successfully and failed on others with the same error: 
Bad timestamp external representation ''.

The table that loaded successfully had datetime data in the exact same format as
this one. I have taken this file apart and successfully loaded it one or two fields at a time, including the datetime fields (into timestamp) but it will not load as is. I've changed the delimiter to \t and tried \. at the end.   I've changed the field types from timestamp to char(25) and it loaded fine. I tried to create another table and cast to timestamp from char.  That's not allowed. 

Any help will be appreciated.

Here is the version, the table description, the COPY stmt with error, and the input file(it's only one row).  

ems=# select version();
PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.1 (SuSE Linux)

ems=# \d edadvisor_char;
Table "public.edadvisor_char"
 
 advisor1             | character varying(60)       
 whenent1           | timestamp without time zone 
 advisor2             | character varying(60) 
 whenent2           | timestamp without time zone 
 advisor3             | character varying(60)
 whenent3           | timestamp without time zone 
 advkey               | character(1)              
 whenchange       | timestamp without time zone
 bhhwhenchange  | timestamp without time zone 
 bmhwhenchange | timestamp without time zone 
 kmcwhenchange | timestamp without time zone 
 merwhenchange  | timestamp without time zone 
 sjhwhenchange   | timestamp without time zone 


ems=# copy edadvisor_char from '/home/xxxxxx/test_data.txt' using delimiters ',';
ERROR:  copy: line 1, Bad timestamp external representation ''
ems=# 

****** test_data.txt ********
Off E.D. Rotation,2004-09-01 00:00:01.000,testing,2004-09-01 00:00:06.000,,,1,2004-09-02 12:56:43.000,2004-08-05 15:13:10.000,2004-08-05 14:29:01.000,2004-08-05 14:57:32.000,2004-08-05 13:49:46.000,2004-08-06 14:05:07.000

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Bad Timestamp Error with COPY
@ 2004-11-10 22:14  Stephan Szabo <sszabo@megazone.bigpanda.com>
  parent: Sharon Schooley <schooleys@co.kern.ca.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Stephan Szabo @ 2004-11-10 22:14 UTC (permalink / raw)
  To: Sharon Schooley <schooleys@co.kern.ca.us>; +Cc: pgsql-admin

On Wed, 10 Nov 2004, Sharon Schooley wrote:

> I am new to Postgresql. I'm trying to load tables from SQLServer bcp
> export, comma delimited.  I'm loading datetime datatype into timestamp.
> I've loaded one table successfully and failed on others with the same
> error:
> Bad timestamp external representation ''.
>
> The table that loaded successfully had datetime data in the exact same
> format as this one. I have taken this file apart and successfully loaded
> it one or two fields at a time, including the datetime fields (into
> timestamp) but it will not load as is. I've changed the delimiter to \t
> and tried \. at the end.  I've changed the field types from timestamp to
> char(25) and it loaded fine. I tried to create another table and cast to
> timestamp from char.  That's not allowed.
>
> Any help will be appreciated.
>
> Here is the version, the table description, the COPY stmt with error,
> and the input file(it's only one row).
>
> ems=# select version();
> PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.1 (SuSE Linux)
>
> ems=# \d edadvisor_char;
> Table "public.edadvisor_char"
>
>  advisor1             | character varying(60)
>  whenent1           | timestamp without time zone
>  advisor2             | character varying(60)
>  whenent2           | timestamp without time zone
>  advisor3             | character varying(60)
>  whenent3           | timestamp without time zone
>  advkey               | character(1)
>  whenchange       | timestamp without time zone
>  bhhwhenchange  | timestamp without time zone
>  bmhwhenchange | timestamp without time zone
>  kmcwhenchange | timestamp without time zone
>  merwhenchange  | timestamp without time zone
>  sjhwhenchange   | timestamp without time zone
>
>
> ems=# copy edadvisor_char from '/home/xxxxxx/test_data.txt' using delimiters ',';
> ERROR:  copy: line 1, Bad timestamp external representation ''
> ems=#
>
> ****** test_data.txt ********

Breaking it up:
advisor1
> Off E.D. Rotation,
whenent1
> 2004-09-01 00:00:01.000,
advisor2
> testing,
whenent2
> 2004-09-01 00:00:06.000,
advisor3
>,
whenent3
>,

whenent3 is getting an empty string for its date and that's not allowed.
If you want empty strings in the file to be treated as null, you can use
NULL AS ''.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-11-10 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-10 21:40 Bad Timestamp Error with COPY Sharon Schooley <schooleys@co.kern.ca.us>
2004-11-10 22:14 ` Stephan Szabo <sszabo@megazone.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox