INSERTing rows from external file
INSERTing rows from external file
От:
Rich Shepard <rshepard@appl-ecosys.com>
Дата:
I have a file with 5500 rows formated as 'INSERT INTO
Re: INSERTing rows from external file
От:
Chris Travers <chris.travers@gmail.com>
Дата:
On Tue, Aug 16, 2011 at 2:34 PM, Rich Shepard wrote: > I have a file with 5500 rows formated as 'INSERT INTO
Re: INSERTing rows from external file
От:
Greg Smith <greg@2ndQuadrant.com>
Дата:
On 08/16/2011 05:34 PM, Rich Shepard wrote: > I have a file with 5500 rows formated as 'INSERT INTO
Re: INSERTing rows from external file
От:
"David Johnston" <polobo@yahoo.com>
Дата:
>> -----Original Message----- >> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Rich Shepard >> Sent: Tuesday, August 16, 2011 5:34 PM >> To: pgsql-general@postgresql.org >> Subject: [GENERAL] INSERTing rows from external file >> >> I have a file with 5500 rows formated as 'INSERT INTO
Re: INSERTing rows from external file
От:
Rich Shepard <rshepard@appl-ecosys.com>
Дата:
On Tue, 16 Aug 2011, Chris Travers wrote:
> What kind of error?
Chris,
Here's the full statement for the last row:
psql:chem_too.sql:5517: ERROR: invalid input syntax for type boolean: ""
LINE 1: ...NS','1996-11-21','Potassium','0.949999988','mg/L','','','','...
^
The column is NULLable and if there's no value a NULL should be entered.
> Do you get the same error by running psql interactively and typing \i
> filename.sql?
Er, thanks for the pointer. I didn't read the psql man page first. Now I'm
using 'psql -f ' and getting the above error.
Thanks,
Rich
Re: INSERTing rows from external file
От:
Rich Shepard <rshepard@appl-ecosys.com>
Дата:
On Tue, 16 Aug 2011, Greg Smith wrote: > Sounds like a problem with your file. Messing up CR/LF characters when > moving things between Windows and UNIX systems is a popular one. Proof it > works: Greg, Excel file imported into LibreOffice and converted to .ods. Columns marked and saved as .csv. Emacs does not display the 'DOS' indicator of CR/LF instead of the UNIX \n because all work was done with linux applications. Using the psql '-f' option worked ... up to a point when psql pointed out to me that I had neglected to put a terminating semicolon on the end of each line. Mea culpa! Now I get an error on a boolean column. See my response to Chris with details. Thanks, Rich
Re: INSERTing rows from external file
От:
Scott Ribe <scott_ribe@elevated-dev.com>
Дата:
On Aug 16, 2011, at 4:13 PM, Rich Shepard wrote: > Here's the full statement for the last row: > > psql:chem_too.sql:5517: ERROR: invalid input syntax for type boolean: "" > LINE 1: ...NS','1996-11-21','Potassium','0.949999988','mg/L','','','','... > ^ > The column is NULLable and if there's no value a NULL should be entered. An empty string is not null. -- Scott Ribe scott_ribe@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice
Re: INSERTing rows from external file
От:
"David Johnston" <polobo@yahoo.com>
Дата:
-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Rich Shepard
Sent: Tuesday, August 16, 2011 6:14 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] INSERTing rows from external file
On Tue, 16 Aug 2011, Chris Travers wrote:
> What kind of error?
Chris,
Here's the full statement for the last row:
psql:chem_too.sql:5517: ERROR: invalid input syntax for type boolean: ""
LINE 1: ...NS','1996-11-21','Potassium','0.949999988','mg/L','','','','...
^
The column is NULLable and if there's no value a NULL should be entered.
> Do you get the same error by running psql interactively and typing \i
> filename.sql?
Er, thanks for the pointer. I didn't read the psql man page first. Now
I'm using 'psql -f ' and getting the above error.
Thanks,
----------------------------------------------------------------------------
---------
Since the error references a specific row of data you should provide that as
well.
Your INSERT statement is syntactically incorrect; the error has nothing to
do with PSQL other than the fact that PSQL is reporting the error to you.
Odds are you are wrapping your Boolean input with single quotes and the
empty string is not valid input for a Boolean. Because of the quotes the
system will not use NULL since the input data is not missing but instead it
has the empty-string as a value.
David J.
Re: INSERTing rows from external file
От:
Rich Shepard <rshepard@appl-ecosys.com>
Дата:
On Tue, 16 Aug 2011, David Johnston wrote: > Your INSERT statement is syntactically incorrect; the error has nothing to > do with PSQL other than the fact that PSQL is reporting the error to you. David, I see that now. > Odds are you are wrapping your Boolean input with single quotes and the > empty string is not valid input for a Boolean. Because of the quotes the > system will not use NULL since the input data is not missing but instead > it has the empty-string as a value. Yep. Gotta' correct them all so the proper columns are listed and those with no values are not. Thanks for pointing out the obvious. Rich