Re: "invalid input syntax for integer" for number with exponent - Mailing list pgsql-novice

From David G. Johnston
Subject Re: "invalid input syntax for integer" for number with exponent
Date
Msg-id CAKFQuwa-qSGUAAuyCMEcUOOnow3Wi4ypj4Lee9B7xAGvSa=6hw@mail.gmail.com
Whole thread Raw
In response to Re: "invalid input syntax for integer" for number with exponent  (Bzzzz <lazyvirus@gmx.com>)
List pgsql-novice
On Wed, Feb 28, 2018 at 2:24 PM, Bzzzz <lazyvirus@gmx.com> wrote:
On Wed, 28 Feb 2018 21:16:37 +0000
Stephen Froehlich <s.froehlich@cablelabs.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.

pgsql-novice by date:

Previous
From: Bzzzz
Date:
Subject: Re: "invalid input syntax for integer" for number with exponent
Next
From: "Dale Schmitz"
Date:
Subject: pg_query won't execute