> 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);