Can't cast from char to integer...

Поиск
Список
Период
Сортировка
От Mike Diehl
Тема Can't cast from char to integer...
Дата
Msg-id 200809291331.12623.mdiehl@diehlnet.com
обсуждение исходный текст
Ответы Re: Can't cast from char to integer...
Список pgsql-general
Hi all.

I'm trying to cut data from one table and put it in another table.  The
problem comes from the fact that the first table has a field that is a
char(x) and the destination table needs that data in an integer.

For example, I'm trying to do this:

insert into data
    select cast('666' as integer) as block_number, phone as phone_number, name
from demo_q;

The data table has a field called block_number that is an integer.  I'm trying
to populate that field with the INTEGER, 666.  (I use 666 for testing since I
would never assign that number/id to an actuall customer.)

When I run this query, I get:

ERROR:  column "block_number" is of type integer but expression is of type
character varying

What am I doing wrong?

TIA,
--
Mike Diehl

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

Предыдущее
От: "Richard Broersma"
Дата:
Сообщение: Re: inserting to a multi-table view
Следующее
От: r_musta
Дата:
Сообщение: Counting unique rows as an aggregate.