Re: Change column type to numeric

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Change column type to numeric
Дата
Msg-id 20080210185255.GA43421@winnie.fuhr.org
обсуждение исходный текст
Ответ на Change column type to numeric  ("Jake Franklin" <jfranklin@denvergeek.net>)
Список pgsql-general
On Sun, Feb 10, 2008 at 11:37:45AM -0700, Jake Franklin wrote:
> test=# alter table foo alter column amount type numeric(10,2) USING
> cast(amount AS numeric);
> ERROR:  invalid input syntax for type numeric: ""
>
> I'm assuming that it's trying to cast a blank value as numeric and
> failing.  Does anyone know of an easy way to work around this?

You could convert the empty strings to NULL:

USING cast(nullif(amount, '') AS numeric)

--
Michael Fuhr

В списке pgsql-general по дате отправления:

Предыдущее
От: "Jake Franklin"
Дата:
Сообщение: Change column type to numeric
Следующее
От: Erik Jones
Дата:
Сообщение: Re: Is PG a moving target?