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

From Joel Burton
Subject Re: can't cast varchar as integer?
Date
Msg-id JGEPJNMCKODMDHGOBKDNIEEICOAA.joel@joelburton.com
Whole thread Raw
In response to can't cast varchar as integer?  (Scott Royston <scroyston@mac.com>)
List pgsql-sql
> what's the reasoning behind not being able to cast a varchar as 
> integer?  this seems very weird to me:
> 
> 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)

Interesting. You can have an intermediate to-text cast:

select cast ( cast ( cast ('123' as varchar) as text) as integer);


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: aggregate...
Next
From: David Stanaway
Date:
Subject: Re: can't cast varchar as integer?