Thread: Problem with COPY FROM

Problem with COPY FROM

From
Harry Yau
Date:
Hi all,
I am trying to copy some date from a text file to pgsql.
I am using pgsql 7.3 version. The problem i am face is that i try to
copy a TEXT field to a table.
I have serveral line in this field.
Let say, I have  a table T1, and three fields with it, F1, F2, F3.
F1 is varchar(5), F2 is text and F3 is int
When I pg_dump T1, it show something like
........
COPY T1(F1, F2) FROM stdin;
00001   Line1\r\nLine2\r\nLine3\r\n   1
00002   LineA\r\nLineB\r\nLineB\r\n   3
\.
.....
I cut it out and run it. It get me the following error message:    ERROR:  copy: line 1, value too long for type
character(5)

Then I thought, the tab(\t) is messed up, so I delete all the space in
between the fields and put a tab by myself. The funny thing happen.
Sometime, it give me the error message   ERROR:  copy: line 2, Missing data for column "F2"

However, somtime it have no error message and no "COPY" to identicate
the sussecc of the command. ( In fact, it didn't copy the data for me!)

Please, could anyone help me a bit with the COPY FROM with text field.

Thank You very Much!

Harry Yau