Re: create new field

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: create new field
Дата
Msg-id 200310060944.47636.josh@agliodbs.com
обсуждение исходный текст
Ответ на create new field  ("Chris Faulkner" <chrisf@oramap.com>)
Список pgsql-sql
Chris,

> template1=# update tab set new_col = "OLD_COL"::int4;
> ERROR:  Cannot cast type character to integer
>
> I understand this - some tables might have characters in the varchar but
> how to get around it in my case ? I know that my character field has only
> integers in it ?

Actually, you just need to use the to_number function as an intermediary:

UPDATE tab SET new_col = CAST(to_number("OLD_COL", '9999') AS INT);

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


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

Предыдущее
От: "Dan Langille"
Дата:
Сообщение: Re: Multiple table join
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: create new field