Re: Type conversion from TEXT to DOUBLE PRECISION

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: Daniel Lau <iedaniel(at)ust(dot)hk>, pgsql-sql(at)postgresql(dot)org, Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Subject: Re: Type conversion from TEXT to DOUBLE PRECISION
Date: 2004-01-09 14:57:25
Message-ID: 23739.1073660245@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Huxton <dev(at)archonet(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Daniel Lau 2004-01-09 15:44:36 Re: Type conversion from TEXT to DOUBLE PRECISION
Previous Message Michael Glaesemann 2004-01-09 09:54:11 Re: Missing data for column