pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: convert to a string
Date: Tue, 6 Mar 2007 14:56:36 +0100
Message-ID: <20070306135636.GM10330@a-kretschmer.de> (raw)
In-Reply-To: <011901c75ff5$57a38930$1102a8c0@dream>
References: <011901c75ff5$57a38930$1102a8c0@dream>

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



view thread (6+ messages)  latest in thread

Message-ID: <20070306135636.GM10330@a-kretschmer.de>
Permalink:  ../20070306135636.GM10330@a-kretschmer.de/
Also on:    postgresql.org/message-id/20070306135636.GM10330@a-kretschmer.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andreas.kretschmer@schollglas.com
  Subject: Re: convert to a string
  In-Reply-To: <20070306135636.GM10330@a-kretschmer.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox