Re: Returning String as Integer

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Jorge Godoy <jgodoy(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Returning String as Integer
Date: 2006-05-06 15:39:16
Message-ID: 20060506153916.GA3434@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, May 05, 2006 at 18:52:19 -0300,
Jorge Godoy <jgodoy(at)gmail(dot)com> 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)

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message kernel.alert kernel.alert 2006-05-06 17:27:41 problem with uniques and foreing keys
Previous Message Markus Schaber 2006-05-06 13:50:01 Re: Most efficient way to hard-sort records