Re: Type conversion from TEXT to DOUBLE PRECISION - Mailing list pgsql-sql

From Tom Lane
Subject Re: Type conversion from TEXT to DOUBLE PRECISION
Date
Msg-id 23739.1073660245@sss.pgh.pa.us
Whole thread Raw
In response to Re: Type conversion from TEXT to DOUBLE PRECISION  (Richard Huxton <dev@archonet.com>)
Responses Re: Type conversion from TEXT to DOUBLE PRECISION
List pgsql-sql
Richard Huxton <dev@archonet.com> writes:
> Since your error seems to be complaining about a space, I'd guess you've got 
> other than numeric values in _aaa.

In fact, with a bit of experimentation I see the same error message:

regression=# select to_number('12345', '99999');to_number
-----------    12345
(1 row)

regression=# select to_number('1234 ', '99999');to_number
-----------     1234
(1 row)

regression=# select to_number(' 1234', '99999');to_number
-----------     1234
(1 row)

regression=# select to_number('     ', '99999');
ERROR:  invalid input syntax for type numeric: " "
regression=# select to_number('zzzzz', '99999');
ERROR:  invalid input syntax for type numeric: " "
regression=#

The error message's report of the input string seems a tad misleading,
especially in the last case.  (Karel, is this fixable?)  But anyway,
it sure looks like the problem is bad input data.
        regards, tom lane


pgsql-sql by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Missing data for column
Next
From: Daniel Lau
Date:
Subject: Re: Type conversion from TEXT to DOUBLE PRECISION