pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bart Degryse <Bart.Degryse@indicator.be>
To: pgsql-sql@postgresql.org
Cc: Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it>
Subject: Re: convert to a string
Date: Tue, 06 Mar 2007 15:38:34 +0100
Message-ID: <45ED8AFA.A3DD.0030.0@indicator.be> (raw)
In-Reply-To: <01be01c75ffc$3b333f00$1102a8c0@dream>
References: <011901c75ff5$57a38930$1102a8c0@dream>
	<45ED80AB.A3DD.0030.0@indi cator.be>
	<01be01c75ffc$3b333f00$1102a8c0@dream>

As Andreas already asked: do you really have a good reason to store numbers as text
If so, show us some more information: table definition, some table data, a complete (vb?) function/property get, ... anything that is directly involved.


>>> "Shavonne Marietta Wijesinghe" <shavonne.marietta@studioform.it> 2007-03-06 15:32 >>>
when i try the 
set oRs = oConn.Execute("SELECT N_GEN::int FROM MyTable ORDER BY N_GEN DESC") 
it returns 1 and for the rest i doens't change. alsways 10
 :(


----- Original Message ----- 
From: Bart Degryse ( mailto:Bart.Degryse@indicator.be ) 
To: pgsql-sql@postgresql.org 
Sent: Tuesday, March 06, 2007 2:54 PM
Subject: Re: [SQL] convert to a string

I assume GetFieldValue is the name of a VB function or property get?
 
Try either
  Set oRs = oConn.Execute("SELECT N_GEN::int FROM MyTable ORDER BY N_GEN DESC")
or
   GetFieldValue = cint(oRs("N_GEN")) + 1
or
   GetFieldValue = clng(oRs("N_GEN")) + 1

In the last two cases make sure that the function or property get returns an int or long
Also remember that if oRs("N_GEN") is NULL the sum will also be NULL

>>> "Shavonne Marietta Wijesinghe" <shavonne.marietta@studioform.it> 2007-03-06 14:42 >>>
Hello 

i have a column N_GEN in postgreSql defined as text. In this coloumn i insert a number 10

N_GEN (text) = 10 
 

 

on error resume next
  Set oRs = oConn.Execute("SELECT N_GEN FROM MyTable ORDER BY N_GEN DESC")
  If err <> 0 then 'If table not found
   GetFieldValue = "1"
  else
   GetFieldValue = oRs("N_GEN") + 1
  End If
 
But it doesn't add the 1 to my N_GEN
How can i set the Recordset to convert the string to a number and then add 1 to it??
 
Shavonne Wijesinghe
http://www.studioform.it ( http://www.studioform.it/ )
 

 

view thread (6+ messages)  latest in thread

Message-ID: <45ED8AFA.A3DD.0030.0@indicator.be>
Permalink:  ../45ED8AFA.A3DD.0030.0@indicator.be/
Also on:    postgresql.org/message-id/45ED8AFA.A3DD.0030.0@indicator.be

 · 

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: Bart.Degryse@indicator.be, shavonne.marietta@studioform.it
  Subject: Re: convert to a string
  In-Reply-To: <45ED8AFA.A3DD.0030.0@indicator.be>

* 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