Skip site navigation (1) Skip section navigation (2)

error loading data with copy

From: Fred Wohlfert <fredwohlfert(at)ehbmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: error loading data with copy
Date: 2004-11-17 16:43:05
Message-ID: 419B7F99.1080407@ehbmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
I am trying to load data with the copy function,

*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'"
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 laod.

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),
       BIN3                 CHAR(4),
       BIN4                 CHAR(4),
       PUBSTNUM             CHAR(10),
       TITLE                CHAR(40),
       BUYPRICE             NUMERIC(6),
       SELLPRICE            NUMERIC(6),
       INVENTORY1           NUMERIC(4),
       INVENTORY2           NUMERIC(4),
       CURINV               NUMERIC(4),
       COPYPUR              NUMERIC(4),
        RESTOCKBIN           NUMERIC(4),
       H8DATE               DATE,
       BUYER                CHAR(2),
       PRICED               CHAR(2),
       PULP                 NUMERIC(4),
       PUBPRICE             NUMERIC(7,2),
       HALFCOM              NUMERIC(7,2),
       KEEP2                CHAR(1),
       NEWDATE2             DATE,
       CONDITION            CHAR(1),
       FEATURE              CHAR(2),
       RESTOCKEDX           NUMERIC(2),
       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);




Responses

pgsql-admin by date

Next:From: Jodi KanterDate: 2004-11-17 17:10:00
Subject: error on start
Previous:From: Vishal Kashyap @ [SaiHertz]Date: 2004-11-17 13:53:58
Subject: Re: psql: FATAL: user "root" does not exist createdb: database creation failed

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group