Re: [SQL] convert text to number or number to text - Mailing list pgsql-sql

From José Soares
Subject Re: [SQL] convert text to number or number to text
Date
Msg-id 371F1510.F86C876B@sferacarta.com
Whole thread Raw
In response to convert text to number or number to text  (JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>)
List pgsql-sql
<tt>JT Kirkpatrick ha scritto:</tt><blockquote type="CITE"><tt>I'm trying to do an update query that compares an int4
fieldto a variable</tt><br /><tt>which I think contains a string (it was passed in through cgi.pm).  can I</tt><br
/><tt>convertthat string to an integer? - it will always be a number passing</tt><br /><tt>through.  I vaguely remember
oraclehaving a to_number function - does</tt><br /><tt>postgres have something
similar?</tt><tt></tt><p><tt>jt</tt></blockquote><tt>Trythis:</tt><tt></tt><p><tt>prova=> create table test(t text,
iinteger);</tt><br /><tt>CREATE</tt><tt></tt><p><tt>prova=> insert into test values('123',123);</tt><br /><tt>INSERT
645791</tt><tt></tt><p><tt>prova=> select cast(i as text),cast(t as int)from test;</tt><br /><tt>text|int4</tt><br
/><tt>----+----</tt><br/><tt> 123| 123</tt><br /><tt>(1 row)</tt><p>José <br />  

pgsql-sql by date:

Previous
From: George Moga
Date:
Subject: Re: [SQL] default in ALTER
Next
From: José Soares
Date:
Subject: Re: [SQL] convert text to number or number to text