X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3C573D1B541 for ; Mon, 6 Oct 2003 16:47:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03480-04 for ; Mon, 6 Oct 2003 13:46:31 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 78901D1B506 for ; Mon, 6 Oct 2003 13:46:25 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3732437; Mon, 06 Oct 2003 09:47:01 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Chris Faulkner" , "Pgsql-Sql" Subject: Re: create new field Date: Mon, 6 Oct 2003 09:44:47 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310060944.47636.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/74 X-Sequence-Number: 15474 Chris, > template1=# update tab set new_col = "OLD_COL"::int4; > ERROR: Cannot cast type character to integer > > I understand this - some tables might have characters in the varchar but > how to get around it in my case ? I know that my character field has only > integers in it ? Actually, you just need to use the to_number function as an intermediary: UPDATE tab SET new_col = CAST(to_number("OLD_COL", '9999') AS INT); -- Josh Berkus Aglio Database Solutions San Francisco