X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA30852B58 for ; Tue, 12 Jul 2005 15:18:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35878-08 for ; Tue, 12 Jul 2005 18:18:17 +0000 (GMT) Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id D107B52C6F for ; Tue, 12 Jul 2005 15:16:48 -0300 (ADT) Received: from resmta03.ono.com (smtp.ono.com [62.42.230.12]) by svr2.postgresql.org (Postfix) with ESMTP id 99EB8F1D15 for ; Tue, 12 Jul 2005 13:45:33 +0100 (BST) Received: from Zeus (84.120.1.142) by resmta03.ono.com (7.2.052) id 42B998410015AB2C for pgsql-sql@postgresql.org; Tue, 12 Jul 2005 14:49:25 +0200 From: "Mauricio Fernandez" To: Subject: Re: PostgreSQL - ERROR: Cannot cast type character varying to integer Date: Tue, 12 Jul 2005 14:49:46 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <42D3AACF.98C5629B@rodos.fzk.de> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.312 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200507/100 X-Sequence-Number: 22078 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@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