X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 30C84D1F0A2 for ; Tue, 4 May 2004 12:07:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99688-09 for ; Tue, 4 May 2004 12:07:18 -0300 (ADT) Received: from p15124592.pureserver.info (p15124592.pureserver.info [217.160.181.164]) by svr1.postgresql.org (Postfix) with ESMTP id C209ED1BA93 for ; Tue, 4 May 2004 12:07:17 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by p15124592.pureserver.info (Postfix) with ESMTP id B7E591795A for ; Tue, 4 May 2004 17:07:15 +0200 (CEST) Received: from sarge (p508A9FF5.dip0.t-ipconnect.de [80.138.159.245]) by p15124592.pureserver.info (Postfix) with ESMTP id 106D417959 for ; Tue, 4 May 2004 17:07:15 +0200 (CEST) Received: from mk-os.de (unknown [192.168.0.210]) by sarge (Postfix) with ESMTP id 3404B3EC05 for ; Tue, 4 May 2004 17:07:14 +0200 (CEST) Message-ID: <4097B205.2040402@mk-os.de> Date: Tue, 04 May 2004 17:08:53 +0200 From: Martin Knipper User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-AT; rv:1.6) Gecko/20040113 X-Accept-Language: de-at, de, en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: typecasting numeric(18,4) to varchar/text References: <63340-22004524133531385@M2W046.mail2web.com> <20040504143745.GA10467@phlogiston.dyndns.org> In-Reply-To: <20040504143745.GA10467@phlogiston.dyndns.org> X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS at MK-OS X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200405/37 X-Sequence-Number: 17751 Am 04.05.2004 16:37 schrieb Andrew Sullivan: > On Tue, May 04, 2004 at 09:35:31AM -0400, ashok@kalculate.com wrote: > >>create table a (a numeric(18,4)); >>create table b (b varchar(25)); >>insert into a values(12000.43); >>insert into b select (a.a)::varchar; > > > Which version is that? Here's my session: > > andrewtest=# create table a (a numeric(18,4)); > CREATE TABLE > andrewtest=# create table b (b varchar(25)); > CREATE TABLE > andrewtest=# insert into a values(12000.43); > INSERT 17168 1 > andrewtest=# insert into b select (a.a)::varchar; > INSERT 17169 1 > > That's on 7.4.2. You might want to try casting to text first. > Yes, it also works for me with Version 7.4.2. I found an older postgres DB with Version 7.2 and I get the same error as ashok demo=# select a::varchar from a; ERROR: Cannot cast type 'numeric' to 'character varying' demo=# select a::text from a; ERROR: Cannot cast type 'numeric' to 'text' demo=# select '\'' || a || '\'' from a;; ERROR: Unable to identify an operator '||' for types 'unknown' and 'numeric' You will have to retype this query using an explicit cast Greetings, Martin -- Martin Knipper www : http://www.mk-os.de Mail : knipper@mk-os.de Random Signature: ----------------- while( !asleep() ) sheep++;