Char to Int - Mailing list pgsql-general

From Rick Seeger
Subject Char to Int
Date
Msg-id HKEPLMBPEGFGAKDKKAEDMEJFFKAA.rick@nettheory.com
Whole thread Raw
In response to Re: int1?  (Sean Chittenden <sean@chittenden.org>)
Responses Re: Char to Int  ("Rick Seeger" <rick@nettheory.com>)
List pgsql-general
I'm trying to convert a var char to an int. I tried a couple methods
described in the documentation, but can't seem to get it to work. Any
thoughts?

In this example, the field my_id is character varying(16):

rs=# insert into table2
rs=# select my_Id::INT
rs=# from table1;
ERROR:  Cannot cast type character to integer

rs=#
rs=# insert into table2
rs=# select CASE(my_Id as integer)
rs=# from table1;
ERROR:  Cannot cast type character to integer

Any help or links to appropriate documentation appreciated!

--Rick



pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Virtual Machines and postgres
Next
From: "Floyd Shackelford"
Date:
Subject: Table analyzer