X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 89D953A4263 for ; Wed, 10 Nov 2004 22:14:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40973-07 for ; Wed, 10 Nov 2004 22:14:21 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 8986D3A4036 for ; Wed, 10 Nov 2004 22:14:22 +0000 (GMT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 6E290358FA; Wed, 10 Nov 2004 14:14:22 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 6C8B1358F8; Wed, 10 Nov 2004 14:14:22 -0800 (PST) Date: Wed, 10 Nov 2004 14:14:22 -0800 (PST) From: Stephan Szabo To: Sharon Schooley Cc: pgsql-admin@postgresql.org Subject: Re: Bad Timestamp Error with COPY In-Reply-To: Message-ID: <20041110140716.H97519@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/94 X-Sequence-Number: 15479 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 ''.