Thread: invalid input syntax for integer: ""

invalid input syntax for integer: ""

From
"Sebastian Tewes"
Date:
Hello :-)
 
got a little prob...
 
so my table
 
create table warengruppen ( kennung char (1),
                                holder int,
                     HauptWarenGruppe int,
                        BezHWG varchar (50),
                          WarenGruppe int,
                         BezWG varchar (50));
 
 
the copy syntax
 
copy warengruppen FROM '/usr/pgsql/datanorm.wrg' with DELIMITER ';';
 
and a smal part of my 'datanorm.wrg'
 
 
S;;011;Dachsteine+Formst.;;;
S;;011;;0111;Dachst.glatt(Biber);
S;;011;;0112;Dachst.glatt(Tegal.);
S;;011;;0114;Dachst.mulde(Donau);
S;;011;;0116;Dachst.symm.(Frankf);
S;;011;;0118;Dachst.asym.(Dop.-S);
S;;011;;0119;Dachst.Sonstige;
S;;012;Dachziegel+Formst.;;;
S;;012;;0121;Biberschwanzziegel;
S;;012;;0122;Hohlz.+Krempz.;
S;;012;;0123;Mnch + Nonne;
S;;012;;0124;Strangfalzziegel;
S;;012;;0125;Falzz.(Doppelmulde);
S;;012;;0126;Flachdachziegel;
S;;012;;0127;Verschiebeziegel;
S;;012;;0129;Ziegel Sonstige;
S;;013;Faserzementplatten;;;
S;;013;;0131;Dach+Fassadenplatten;
S;;013;;0133;Wellplatten;
S;;013;;0135;Tafeln;
S;;013;;0137;Elemente;
S;;014;Fassadenpl.speziell;;;
S;;014;;0141;Asphalt;
 
and the error message
 
ERROR:  invalid input syntax for integer: ""
CONTEXT:  COPY warengruppen, line 1, column holder: ""
i know it's hard to fill the integer colume    holder    with nothing out of csv table.. but it's the same with the colume   WarenGruppe so i can't use a char type... so mybe someone know a litte trick to save me ?? don't like to reformat 10MB datasource ...
 
thank's 
 
Sebastian
 

Re: invalid input syntax for integer: ""

From
"scott.marlowe"
Date:
On Sat, 1 May 2004, Sebastian Tewes wrote:

> Hello :-)
> 
> got a little prob... 
> 
> so my table 
> 
> create table warengruppen ( kennung char (1),
>                                 holder int,
>                      HauptWarenGruppe int,
>                         BezHWG varchar (50),
>                           WarenGruppe int,
>                          BezWG varchar (50));
> 
> 
> the copy syntax 
> 
> copy warengruppen FROM '/usr/pgsql/datanorm.wrg' with DELIMITER ';';
> 
> and a smal part of my 'datanorm.wrg'
> 
> 
> S;;011;Dachsteine+Formst.;;;
> S;;011;;0111;Dachst.glatt(Biber);
> S;;011;;0112;Dachst.glatt(Tegal.);

the problem here is that "" is not an integer. 

0 is.  If you were to write a simple script file to process the input file 
and turn the empty fields into 0s where they should be because they're 
integers you're set.

OR, you can build a temp table with all text columns, import into that, 
then use a select query to change the blank text columns to the character 
0, then import that into the target table.