Re: [SQL] convert text to number or number to text

Поиск
Список
Период
Сортировка
От José Soares
Тема Re: [SQL] convert text to number or number to text
Дата
Msg-id 371F1510.F86C876B@sferacarta.com
обсуждение исходный текст
Ответ на convert text to number or number to text  (JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>)
Список 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 по дате отправления:

Предыдущее
От: George Moga
Дата:
Сообщение: Re: [SQL] default in ALTER
Следующее
От: José Soares
Дата:
Сообщение: Re: [SQL] convert text to number or number to text