Re: COPY isn't working right for me

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Jeff S(dot)" <pgsqluser(at)yahoo(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: COPY isn't working right for me
Date: 2001-02-13 17:04:37
Message-ID: Pine.LNX.4.30.0102131803350.1615-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jeff S. writes:

> create table member (
> member_id serial not null,
> fname varchar(25) not null,
> lname varchar(25) not null,
> member_since date not null,
> Primary Key (member_id)
> );

> My member.txt file looks like this:
>
> Joe Smith 2000/01/14
> Frank Jones 2000/06/21
> Mike Davis 2000/09/24
>
> Here's the copy command I use:
>
> COPY member FROM '/tmp/member.txt';
>
> But I'm getting the following error:
> ERROR: copy: line 1, pg_atoi: error in "Joe": can't
> parse "Joe"
>
> I'm assuming this has to do with the member_id with
> type serial. How do I import into this without having
> to add the OID's to each of the rows in the text file?

You can't, using COPY. You'll have to preprocess your file, either into
INSERT statements, are prepend your own id's.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Olaf Marc Zanger 2001-02-14 08:02:54 constraint/restrict
Previous Message Ines Klimann 2001-02-13 16:20:39 How to create a type ?