even after laboriously following previous post, cannot cast from char to int

Поиск
Список
Период
Сортировка
Искать

even after laboriously following previous post, cannot cast from char to int

От:
Lille Penguini <lille.penguini@gmail.com>
Дата:
Hey,

Re casting char columns to int, I've worked all the proposed solutions from previous post-gres mailing list posts, but to no avail.

None of the ALTER TABLE proposed fixes worked for me, and now I have a new INTEGER type column created, I execute the following:

UPDATE zip_code_data SET county_fips_rev = CAST(county_fips as INTEGER);

...and this is what I get:

ERROR:  invalid input syntax for type numeric: "     "

What is this telling me?

Thanks,

Lille

Re: even after laboriously following previous post, cannot cast from char to int

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Lille Penguini  writes:
> Re casting char columns to int, I've worked all the proposed solutions
> from previous
> post-gres mailing list
> posts,
> but to no avail.

> None of the ALTER TABLE proposed fixes worked for me, and now I have a new
> INTEGER type column created, I execute the following:

> UPDATE zip_code_data SET county_fips_rev = CAST(county_fips as INTEGER);

> ...and this is what I get:

> ERROR:  invalid input syntax for type numeric: "     "

> What is this telling me?

It's telling you you have a row in which the value is all blanks,
and that doesn't look enough like a number to satisfy the cast function.
You need to clean the data ...

			regards, tom lane
FAQ