niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » rdb
Problems converting Real to Char
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
Richard Maher
*nix forums Guru Wannabe


Joined: 15 Jun 2005
Posts: 275

PostPosted: Fri Nov 04, 2005 11:58 pm    Post subject: Re: Problems converting Real to Char Reply with quote

Hi,

Quote:
something like that: "1.020000000E m2" completely diferent,

But that's what floating point numbers look like isn't it?

Quote:
ps.: If I use "cast(Cast(table.number as integer) as varchar(10)) ||
'-' || table.mesure " it works but losing precision...

You could always use a scaled integer (For example INTEGER(2)) for two
decimal places or ((table.number + 0.005) as integer(2)) But if you knew it
had two decimal places then I guess you wouln't be storing it as a real?

Regards Richard Maher

PS. If all else fails you could always right an external function to do
whatever conversion activities that you'd like. I'd suggest picking a
language that doesn't support scaled integers and then finding the
appropriate CPU-burning subroutine in that languages run-time library. Then,
at least, the output will be consistent (whether right or wrong).


"Dr. Dweeb" <NOSPAM_5msg0h202@sneakemail.com> wrote in message
news:436bdac9$0$78279$157c6196@dreader1.cybercity.dk...
Quote:
VitorEugenio wrote:
My friends, I never worked with RDb before, but I developed a software
using Oracle 9i and now I had to use RDB... and I'm having lots of
problems.


I have a column declared as REAL and another one as Char, I need to
put

them toguether in a string.


Ex.: Field - Number (REAL) Value: 100.02
Field - Mesure (char) Value: "m2"
I have to make a SELECT and return like this "100,02 m2"


When I was using oracle 9i I just put "table.number || '-' ||
table.mesure" and it was perfect... but with RDB I can't use this way,
I have to convert REAL in CHAR first, but when I do this the result is
something like that: "1.020000000E m2" completely diferent, how can I
solve this?


ps.: If I use "cast(Cast(table.number as integer) as varchar(10)) ||
'-' || table.mesure " it works but losing precision...


Please, it seems to be a stupid question.. but I never worked with
this

database before and I'm very lost....


tnks...

I had that problem once, sadly I cannot remember how I solved it and I am
not near a machine right now. I will try and have a look at it next week.

Dr. Dweeb

Back to top
Dr. Dweeb
*nix forums Guru Wannabe


Joined: 23 Jul 2005
Posts: 125

PostPosted: Fri Nov 04, 2005 10:03 pm    Post subject: Re: Problems converting Real to Char Reply with quote

VitorEugenio wrote:
Quote:
My friends, I never worked with RDb before, but I developed a software
using Oracle 9i and now I had to use RDB... and I'm having lots of
problems.


I have a column declared as REAL and another one as Char, I need to
put

them toguether in a string.


Ex.: Field - Number (REAL) Value: 100.02
Field - Mesure (char) Value: "m2"
I have to make a SELECT and return like this "100,02 m2"


When I was using oracle 9i I just put "table.number || '-' ||
table.mesure" and it was perfect... but with RDB I can't use this way,
I have to convert REAL in CHAR first, but when I do this the result is
something like that: "1.020000000E m2" completely diferent, how can I
solve this?


ps.: If I use "cast(Cast(table.number as integer) as varchar(10)) ||
'-' || table.mesure " it works but losing precision...


Please, it seems to be a stupid question.. but I never worked with
this

database before and I'm very lost....


tnks...

I had that problem once, sadly I cannot remember how I solved it and I am
not near a machine right now. I will try and have a look at it next week.

Dr. Dweeb
Back to top
VitorEugenio
*nix forums beginner


Joined: 27 Aug 2005
Posts: 1

PostPosted: Sat Aug 27, 2005 3:23 pm    Post subject: Problems converting Real to Char Reply with quote

My friends, I never worked with RDb before, but I developed a software
using Oracle 9i and now I had to use RDB... and I'm having lots of
problems.


I have a column declared as REAL and another one as Char, I need to put

them toguether in a string.


Ex.: Field - Number (REAL) Value: 100.02
Field - Mesure (char) Value: "m2"
I have to make a SELECT and return like this "100,02 m2"


When I was using oracle 9i I just put "table.number || '-' ||
table.mesure" and it was perfect... but with RDB I can't use this way,
I have to convert REAL in CHAR first, but when I do this the result is
something like that: "1.020000000E m2" completely diferent, how can I
solve this?


ps.: If I use "cast(Cast(table.number as integer) as varchar(10)) ||
'-' || table.mesure " it works but losing precision...


Please, it seems to be a stupid question.. but I never worked with this

database before and I'm very lost....


tnks...
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Tue Dec 02, 2008 6:23 am | All times are GMT
navigation Forum index » Databases » rdb
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Winbind problems for ADS authentication nlinley networking 1 Tue Sep 19, 2006 9:22 am
No new posts problems using oddmuse with mod_perl2 inside apache2.2 pe... Fergus McMenemie Perl 0 Fri Jul 21, 2006 9:48 am
No new posts Problems with make-kpkg and skas patch Todd A. Jacobs Debian 0 Fri Jul 21, 2006 12:30 am
No new posts How do I render JPEG Data stored in char* buffer? On the Sparrow C++ 2 Thu Jul 20, 2006 8:44 pm
No new posts const char as class member markww C++ 3 Thu Jul 20, 2006 7:55 pm

Mortgage Calculator | Big Brother 9 | Credit Counseling | Mortgage Calculator | Mortgages
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2256s ][ Queries: 20 (0.1469s) ][ GZIP on - Debug on ]