Thread: Re: PostgreSQL - ERROR: Cannot cast type character varying to integer
Re: PostgreSQL - ERROR: Cannot cast type character varying to integer
From
"Mauricio Fernandez"
Date:
thanks for the answer. i get it too as sum(int4(unidades::text)) Maybe somebody will need this answer too, so i want to add some info I get from other list: We can know wich CAST we have in our DB with this view: create view showcasts as select t.typname as source, t1.typname as target, p.proname as function, (select case when c.castcontext= 'e' then 'Must use Explicit Cast' else ( select case when c.castcontext = 'i' then 'Implicitcast for expressions and assignments' else 'Implicit cast only for assignments' end) end) as casttype from pg_cast c, pg_type t, pg_type t1, pg_proc p where c.castsource = t.oid and c.casttarget = t1.oidand c.castfunc = p.oid; I hope this can be helpfull. again thanks to all. -----Mensaje original----- De: ch@rodos.fzk.de [mailto:ch@rodos.fzk.de] Enviado el: martes, 12 de julio de 2005 13:35 Para: Mauricio Fernandez CC: pgsql-sql@postgresql.org Asunto: Re: [SQL] PostgreSQL - ERROR: Cannot cast type character varying to integer Under PostgreSQL 7.3 it was necessary to use an intermediate cast to text when converting from varchar to int4. sum( unidades::text::int4 ) should do. Regards, Christoph