Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 885F94762E9 for ; Tue, 14 May 2002 17:54:21 -0400 (EDT) Received: from temp.joelburton.com (unknown [209.190.238.101]) by postgresql.org (Postfix) with ESMTP id 9BF444759C7 for ; Tue, 14 May 2002 17:20:18 -0400 (EDT) Received: from joeltf0d13cyyp (unknown [209.190.238.100]) by temp.joelburton.com (Postfix) with SMTP id B2ADD2B981; Tue, 14 May 2002 17:25:26 -0400 (EDT) From: "Joel Burton" To: "Scott Royston" , Subject: Re: can't cast varchar as integer? Date: Tue, 14 May 2002 17:20:20 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-reply-to: <4EE21904-676C-11D6-BF4D-000393577144@mac.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200205/142 X-Sequence-Number: 7778 > 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);