Re: PostgreSQL - ERROR: Cannot cast type character varying to integer

From: "Mauricio Fernandez" <mfacontacto(at)ono(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: PostgreSQL - ERROR: Cannot cast type character varying to integer
Date: 2005-07-12 12:49:46
Message-ID: MEEKIHGNNCKMHBAHDPNNEEELCDAA.mfacontacto@ono.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 'Implicit cast 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.oid and
c.castfunc = p.oid;

I hope this can be helpfull.

again thanks to all.

-----Mensaje original-----
De: ch(at)rodos(dot)fzk(dot)de [mailto:ch(at)rodos(dot)fzk(dot)de]
Enviado el: martes, 12 de julio de 2005 13:35
Para: Mauricio Fernandez
CC: pgsql-sql(at)postgresql(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-07-12 19:12:50 Re: Copy user privileges
Previous Message Graham Vickrage 2005-07-12 12:21:21 Copy user privileges