?
Solved

Problem in Sybase

Posted on 2003-03-11
11
Medium Priority
?
261 Views
Last Modified: 2008-02-01
hi,
  I have column named 'rate' with datatype 'float' in  a table.
I am trying to insert values into that table.  Values are stored in a different form
like,

when i insert 65.235 for 'rate',
it is getting inserted as   65.239999999999995
I do not want this to happen.  Even round() fn. is not functioning here.

what is the solution other changing the datatype other than float.


0
Comment
Question by:Renukak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 6

Expert Comment

by:DaniPro
ID: 8117739
If you use ASA, try to use

TRUNCNUM( 65.235, 3 )
0
 

Author Comment

by:Renukak
ID: 8118081
the fn. TRUNCNUM is not running in my m/c. It is asking me to enable some Java services to run this command.
Pl. give me some other option.  This is urgent.
0
 

Author Comment

by:Renukak
ID: 8118099
the fn. TRUNCNUM is not running in my m/c. It is asking me to enable some Java services to run this command.
Pl. give me some other option.  This is urgent.
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 6

Expert Comment

by:DaniPro
ID: 8118120
If you using ASA v.5 or lowered you can use

SELECT TRUNCATE( 65.235, 3 )
0
 

Author Comment

by:Renukak
ID: 8118134
the fn. TRUNCNUM is not running in my m/c. It is asking me to enable some Java services to run this command.
Pl. give me some other option.  This is urgent.
0
 

Author Comment

by:Renukak
ID: 8118177
I am using ASE which does not support TRUNCATE OR TRUNCNUM
aNY other solution please???
0
 

Author Comment

by:Renukak
ID: 8118201
I am using ASE which does not support TRUNCATE OR TRUNCNUM
aNY other solution please???
0
 
LVL 4

Accepted Solution

by:
gletiecq earned 120 total points
ID: 8120186
"float" is an approximate numeric datatype.  If you want to have exact precision, I'd recommend using NUMERIC or MONEY datatypes, even though you seem to not want to do this.  If your requirement is for exact numeric precision, use datatypes that support exact numeric precision, not something like "float".

If this value is just simply inappropriate for display purposes, you may want to have the application format the data in the way you want it rather than play games on the database that impact only presentation layer stuff.

Sorry I couldn't give you a better answer.

Greg
0
 
LVL 5

Expert Comment

by:berXpert
ID: 8219966
Maybe I'm late but you can try

select convert( numeric(11,3), rate) from your_table

and you will get your result as wanted.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question