copy data into table error

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: copy data into table error
Date: 2002-11-26 20:56:09
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB04C742CA@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Running PostgreSQL 7.2.1 on RedHat Linux 7.2.

I have a table that looks like this:

[snip]
drop table t_risk;
create table t_risk (
"ident" char(12),
"num" char(2)
);
[/snip]

I want to copy data from a flat text file. The file
is about 2000 rows and I've gone into vi to change
the delimiters ... it used to be a bunch of white spaced
between the columns, but I've changed that to a \t (tab).

The data looks like this:

[snip]

250860416 01
264137908 02
272385067 01

[/snip]

When I try to use the copy command, I get
an error:

[snip]

\copy t_risk FROM '/tmp/test.txt' USING DELIMITERS '\t'

ERROR: copy: line 1, value too long for type character(2)
lost synchronization with server, resetting connection
[/snip]

But when I change the table structure from char(2) to char(3)
the data gets imported. I'm thinking I have some odd dos
or control character (^M) in the column, but, when I use vi, I
can't find it and I've stripped out all spaces. What is
the error talking about? What is in the last column (text file)
that PostgreSQL is seeing that I (or, vi) can not?

Thanks for any pointers.

-X

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2002-11-26 20:56:11 Re: order by in for loop in plpgsql does not work
Previous Message Jean-Luc Lachance 2002-11-26 20:45:30 Re: order by in for loop in plpgsql does not work