can't cast varchar as integer? - Mailing list pgsql-sql

From Scott Royston
Subject can't cast varchar as integer?
Date
Msg-id 4EE21904-676C-11D6-BF4D-000393577144@mac.com
Whole thread Raw
Responses Re: can't cast varchar as integer?
Re: can't cast varchar as integer?
List pgsql-sql
Mac OSX, postgresql 7.2.1

what's the reasoning behind not being able to cast a varchar as 
integer?  this seems very weird to me:

LEDEV=# create table test (foo as varchar(5), bar as text);
ERROR:  parser: parse error at or near "as"
LEDEV=# create table test (foo varchar(5), bar text);
CREATE
LEDEV=# insert into test (foo, bar) values ('123', '123');
INSERT 409490 1
LEDEV=# select * from test; foo | bar
-----+----- 123 | 123
(1 row)

LEDEV=# select cast(foo as integer) from test;
ERROR:  Cannot cast type 'character varying' to 'integer'
LEDEV=# select cast(bar as integer) from test; bar
----- 123
(1 row)



pgsql-sql by date:

Previous
From: Mathieu Arnold
Date:
Subject: aggregate...
Next
From: Tom Lane
Date:
Subject: Re: aggregate...