Re: convert to a string

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: convert to a string
Дата
Msg-id 20070306135636.GM10330@a-kretschmer.de
обсуждение исходный текст
Ответ на convert to a string  ("Shavonne Marietta Wijesinghe" <shavonne.marietta@studioform.it>)
Список pgsql-sql
am  Tue, dem 06.03.2007, um 14:42:53 +0100 mailte Shavonne Marietta Wijesinghe folgendes:
> Hello
> 
> i have a column N_GEN in postgreSql defined as text. In this coloumn i insert a
> number 10

Why do you store numbers as text?


> 
> N_GEN (text) = 10
>  
>  
> on error resume next
>   Set oRs = oConn.Execute("SELECT N_GEN FROM MyTable ORDER BY N_GEN DESC")
>  
> But it doesn't add the 1 to my N_GEN

You can't add a number to a string.


> How can i set the Recordset to convert the string to a number and then add 1 to
> it??

You can try to cast it to int:

test=# select '10'::text;text
------10
(1 row)

test=*# select '10'::text::int;int4
------  10
(1 row)


In your Query, change 'SELECT N_GEN FROM' to 'SELECT N_GEN::int FROM'.


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Ezequias Rodrigues da Rocha"
Дата:
Сообщение: Re: Time of executed query
Следующее
От: "Shoaib Mir"
Дата:
Сообщение: Re: Time of executed query