Re: "invalid input syntax for integer" for number with exponent

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bzzzz <lazyvirus(at)gmx(dot)com>
Cc: Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: "invalid input syntax for integer" for number with exponent
Date: 2018-02-28 21:59:15
Message-ID: CAKFQuwa-qSGUAAuyCMEcUOOnow3Wi4ypj4Lee9B7xAGvSa=6hw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Feb 28, 2018 at 2:24 PM, Bzzzz <lazyvirus(at)gmx(dot)com> wrote:

> On Wed, 28 Feb 2018 21:16:37 +0000
> Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com> wrote:
>
> > I'm getting the following error when trying to go from R to a bigint
> > field in PostgreSQL.
> >
> > COPY invalid input syntax for integer: "1.12589990684262e+015"
> >
> > Do I need to convert the number into text manually in R? Exactly what

> about this input is confusing PostgreSQL?
>
>
SELECT '1e4'::integer; -- fails with the same message in PostgreSQL; the
text input function for integers doesn't understand scientific notation.

You will need to ensure that R outputs its numbers in non-scientific format
in order to copy them into PostgreSQL via an intermediate text file.

Take a closer look at this number: is it a FLOAT, not an integer, thus
> you get an error trying to insert a float in an integer column.
>

​Uh, no, that is not what the error is saying...though it is quite possible
if this error wasn't present what you say might happen. The OP does have
confusion somewhere in the schema since the copy command is trying to use
integer while the stated desire is bigint.

David J.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message David Rowley 2018-03-03 10:20:19 Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)?
Previous Message Bzzzz 2018-02-28 21:24:20 Re: "invalid input syntax for integer" for number with exponent