Monday, September 29, 2008

[GENERAL] Can't cast from char to integer...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

No comments: