From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: convert to a string |
Date: | 2007-03-06 13:56:36 |
Message-ID: | 20070306135636.GM10330@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Shoaib Mir | 2007-03-06 13:59:49 | Re: [SQL] Time of executed query |
Previous Message | Ezequias Rodrigues da Rocha | 2007-03-06 13:55:23 | Re: [SQL] Time of executed query |