X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 555269FA38E for ; Sat, 6 May 2006 12:38:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 27864-08 for ; Sat, 6 May 2006 12:38:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id D80599F9431 for ; Sat, 6 May 2006 12:38:29 -0300 (ADT) Received: (qmail 5331 invoked by uid 500); 6 May 2006 15:39:16 -0000 Date: Sat, 6 May 2006 10:39:16 -0500 From: Bruno Wolff III To: Jorge Godoy Cc: pgsql-sql@postgresql.org Subject: Re: Returning String as Integer Message-ID: <20060506153916.GA3434@wolff.to> Mail-Followup-To: Bruno Wolff III , Jorge Godoy , pgsql-sql@postgresql.org References: <18AE59788A3FC640A367E5652E664D8002093F0C@xmb-sjc-237.amer.cisco.com> <200605051852.19596.jgodoy@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200605051852.19596.jgodoy@gmail.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/65 X-Sequence-Number: 25096 On Fri, May 05, 2006 at 18:52:19 -0300, Jorge Godoy wrote: > Em Sexta 05 Maio 2006 18:37, Kashmira Patel (kupatel) escreveu: > > Hi all, > > I have a table with a column of type 'text'. It mainly contains > > numbers. Is there any way to select a value from this column and return > > it as an integer? > > testing=# select '123'::integer; > int4 > ------ > 123 > (1 registro) Note that that isn't the same thing. The '123' above is not treated as being of type text. If you actually wanted to test this conversion you would want to do: bruno=> select '123'::text::integer; int4 ------ 123 (1 row)