Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 43FE7476415 for ; Fri, 24 Jan 2003 05:34:52 -0500 (EST) Received: from tarzan.ugyvitelszolgaltato.hu (unknown [213.163.26.102]) by postgresql.org (Postfix) with ESMTP id 34A524768C7 for ; Fri, 24 Jan 2003 05:34:03 -0500 (EST) Received: from DAQ ([193.80.82.4]) by tarzan.ugyvitelszolgaltato.hu (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id MAA25129; Fri, 24 Jan 2003 12:58:07 +0100 X-Authentication-Warning: tarzan.ugyvitelszolgaltato.hu: Host [193.80.82.4] claimed to be DAQ Date: Fri, 24 Jan 2003 11:28:35 +0100 From: daq X-Mailer: The Bat! (v1.53d) Business Reply-To: daq X-Priority: 3 (Normal) Message-ID: <21242862808.20030124112835@ugyvitelszolgaltato.hu> To: "Luke Pascoe" Cc: pgsql-sql@postgresql.org Subject: Re: CAST from VARCHAR to INT In-Reply-To: <01df01c2c354$2bac5a60$3200000a@K2> References: <01df01c2c354$2bac5a60$3200000a@K2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/393 X-Sequence-Number: 11258 Hello! Like others said you can't cast varchar to int directly. Make your life easier! :) You must write a function like this: create function "int4"(character varying) returns int4 as ' DECLARE input alias for $1; BEGIN return (input::text::int4); END; ' language 'plpgsql'; When you try the cast varchar_field::integer or varchar_field::int4 Postgres call the function named int4 and takes varchar type parameter. DAQ