dbTalk Databases Forums  

Error loading data with COPY

comp.databases.postgresql.admin comp.databases.postgresql.admin


Discuss Error loading data with COPY in the comp.databases.postgresql.admin forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Fred Wohlfert
 
Posts: n/a

Default Error loading data with COPY - 11-18-2004 , 07:33 AM






I am in the prototyping phase of a conversion from dbase to postgresql

I am trying to load data with the copy function,-------

*ham-existing=# \copy invst from '/home/fmwdba/transcoma' using
delimiters ','

I then get the following error --------

ERROR: value too long for type character(7)
CONTEXT: COPY invst, line 1, column stknum: "'0020338'"
ham-existing=#*

however, if I use the insert command and give the field names the data
will load. Can anyone see what I am doing wrong? I need to use the
copy function as I have a lot of data to load.

This is how I created the table
CREATE TABLE Invst (
STKNUM CHAR(7) NOT NULL,
RATIO NUMERIC(4,1),
PUBLET_ CHAR(1),
SORTNUM CHAR(1),
BINNUM CHAR(4),
BIN2 CHAR(4),
WEIGHT NUMERIC(5,2),
MUSICCDSLS NUMERIC(4),
AZTOOHIGH CHAR(1),
AZMAXPRICE NUMERIC(7,2),
OVERSIZE CHAR(1),
KEEPOFFWEB CHAR(1),
NEWSTKNUM CHAR(7),
ROLL_NUM NUMERIC(1),
DATEONAZ DATE,
AZCURINV NUMERIC(3)
);

CREATE UNIQUE INDEX XPKInvst ON Invst
(
STKNUM
);


ALTER TABLE Invst
ADD PRIMARY KEY (STKNUM);




---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: error loading data with copy - 11-21-2004 , 02:43 AM






On Wed, Nov 17, 2004 at 11:43:05AM -0500, Fred Wohlfert wrote:

Quote:
*ham-existing=# \copy invst from '/home/fmwdba/transcoma' using
delimiters ','
\.
ERROR: value too long for type character(7)
CONTEXT: COPY invst, line 1, column stknum: "'0020338'"
Looks like the stknum values in the file have extraneous single
quotes.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.