Re: SQL state: 22P02 Error during a COPY FROM a CSV file - Mailing list pgsql-general

From Richard Huxton
Subject Re: SQL state: 22P02 Error during a COPY FROM a CSV file
Date
Msg-id 49662BB7.9020000@archonet.com
Whole thread Raw
In response to SQL state: 22P02 Error during a COPY FROM a CSV file  (Sherman Brown <ardcsb@earthlink.net>)
List pgsql-general
Sherman Brown wrote:
> CREATE TABLE mp3.songs
> (
>   "Name" character varying[] NOT NULL,
>   "Artist" character varying[] NOT NULL,
>   "Composer" character varying[],
>   "Album" character varying[] NOT NULL,
...

> Here are the first 4 lines from my CSV file:
> Name,Artist,Composer,Album,Grouping,Genre,Size,Time,Disc Number,Disc Count,Track Number,Track Count,Year,Date
Modified,DateAdded,Bit Rate,Sample Rate,Volume Adjustment,Kind,Equalizer,Comments,Play Count,Last Played,Skip
Count,LastSkipped,My Rating,Location 
> Talking About,Susan Tedeschi,"Susan Tedeschi, Doyle Bramhall II & Derek Trucks",Back To The
River,,Blues,4175697,263,1,1,1,11,2008,1/1/200916:38,1/1/2009 16:38,128,44100,,AAC audio file,,,1,1/1/2009
16:47,,,,C:\Documentsand Settings\SB\My Documents\My Music\iTunes\iTunes Music\Susan Tedeschi\Back To The River\01
TalkingAbout.m4a 

> Here is the error I am getting:
>
> ERROR:  array value must start with "{" or dimension information
> CONTEXT:  COPY songs, line 2, column Name: "Talking About"

The problem is that you've defined your "name" column as being an array
of varchar values. That's not what you're providing.

=> CREATE TABLE mp3s (track_name text[]);
CREATE TABLE
=> INSERT INTO mp3s (track_name) VALUES ( '{"first item", "second item"}' );
INSERT 0 1

See the manual: data-types, arrays for more details.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Mohamed
Date:
Subject: Re: to_tsquery, plainto_... avoiding bad input, injections. Is there a builtin function for this ? Escaping?
Next
From: Tom Lane
Date:
Subject: Re: SQL state: 22P02 Error during a COPY FROM a CSV file