pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
COPY isn't working right for me
2+ messages / 2 participants
[nested] [flat]

* COPY isn't working right for me
@ 2001-02-13 15:28  Jeff S. <pgsqluser@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Jeff S. @ 2001-02-13 15:28 UTC (permalink / raw)
  To: pgsql-sql

I have a tab delimited file that I'm trying to import
into an empty table.

I've set the table up as follows:

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?



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



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

* Re: COPY isn't working right for me
@ 2001-02-13 17:04  Peter Eisentraut <peter_e@gmx.net>
  parent: Jeff S. <pgsqluser@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2001-02-13 17:04 UTC (permalink / raw)
  To: Jeff S. <pgsqluser@yahoo.com>; +Cc: 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@gmx.net       http://yi.org/peter-e/




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


end of thread, other threads:[~2001-02-13 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-13 15:28 COPY isn't working right for me Jeff S. <pgsqluser@yahoo.com>
2001-02-13 17:04 ` Peter Eisentraut <peter_e@gmx.net>

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