Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Problem in Sybase

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
Renukak
Asked:
Renukak
1 Solution
 
DaniProCommented:
If you use ASA, try to use

TRUNCNUM( 65.235, 3 )
0
 
RenukakAuthor Commented:
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
 
RenukakAuthor Commented:
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
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
DaniProCommented:
If you using ASA v.5 or lowered you can use

SELECT TRUNCATE( 65.235, 3 )
0
 
RenukakAuthor Commented:
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
 
RenukakAuthor Commented:
I am using ASE which does not support TRUNCATE OR TRUNCNUM
aNY other solution please???
0
 
RenukakAuthor Commented:
I am using ASE which does not support TRUNCATE OR TRUNCNUM
aNY other solution please???
0
 
gletiecqCommented:
"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
 
berXpertCommented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now