CONVERT DECIMAL rounding

This is a discussion on CONVERT DECIMAL rounding within the MySQL Database forums, part of the Database Forums category; Hi Everyone, I am having a problem with mysql, when using convert. I have version 5.0.45 of mysql, ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-17-2007
dkruger
 
Posts: n/a
Default CONVERT DECIMAL rounding

Hi Everyone,

I am having a problem with mysql, when using convert. I have version
5.0.45 of mysql, the problem I am having is if I run a query as
follows, after the insert queries:

insert into testing (value,value2) values ('3.68','7.22');
insert into testing (value,value2) values ('1.21','5.79');

select convert(value,DECIMAL),convert(value2,DECIMAL) FROM testing;

I get the following, where I would expect to get the same values that
were entered with the insert query commands:

+------------------------+-------------------------+
| convert(value,DECIMAL) | convert(value2,DECIMAL) |
+------------------------+-------------------------+
| 1 | 6 |
| 4 | 7 |
+------------------------+-------------------------+
2 rows in set (0.00 sec)

I am having this problem after moving the production database to this
new server, where the old was not rounding the values to the nearest
integer.

Could anyone give me some assistance to what might be the cause? I am
not very familiar with configuring MySQL, but have full access to the
configuration files etc.

Thanks,
David

Reply With Quote
  #2 (permalink)  
Old 10-17-2007
lark
 
Posts: n/a
Default Re: CONVERT DECIMAL rounding

== Quote from dkruger (davidkruger@techie.com)'s article
> Hi Everyone,
> I am having a problem with mysql, when using convert. I have version
> 5.0.45 of mysql, the problem I am having is if I run a query as
> follows, after the insert queries:
> insert into testing (value,value2) values ('3.68','7.22');
> insert into testing (value,value2) values ('1.21','5.79');
> select convert(value,DECIMAL),convert(value2,DECIMAL) FROM testing;
> I get the following, where I would expect to get the same values that
> were entered with the insert query commands:
> +------------------------+-------------------------+
> | convert(value,DECIMAL) | convert(value2,DECIMAL) |
> +------------------------+-------------------------+
> | 1 | 6 |
> | 4 | 7 |
> +------------------------+-------------------------+
> 2 rows in set (0.00 sec)
> I am having this problem after moving the production database to this
> new server, where the old was not rounding the values to the nearest
> integer.
> Could anyone give me some assistance to what might be the cause? I am
> not very familiar with configuring MySQL, but have full access to the
> configuration files etc.
> Thanks,
> David


post a description of the table. run this from cmd line:

desc tablename;


and post the results.


--
POST BY: lark with PHP News Reader ;o)
Reply With Quote
  #3 (permalink)  
Old 10-17-2007
dkruger
 
Posts: n/a
Default Re: CONVERT DECIMAL rounding

On Oct 17, 3:15 pm, lark <ham...@sbcglobal.net> wrote:
> == Quote from dkruger (davidkru...@techie.com)'s article
>
>
>
>
>
> > Hi Everyone,
> > I am having a problem with mysql, when using convert. I have version
> > 5.0.45 of mysql, the problem I am having is if I run a query as
> > follows, after the insert queries:
> > insert into testing (value,value2) values ('3.68','7.22');
> > insert into testing (value,value2) values ('1.21','5.79');
> > select convert(value,DECIMAL),convert(value2,DECIMAL) FROM testing;
> > I get the following, where I would expect to get the same values that
> > were entered with the insert query commands:
> > +------------------------+-------------------------+
> > | convert(value,DECIMAL) | convert(value2,DECIMAL) |
> > +------------------------+-------------------------+
> > | 1 | 6 |
> > | 4 | 7 |
> > +------------------------+-------------------------+
> > 2 rows in set (0.00 sec)
> > I am having this problem after moving the production database to this
> > new server, where the old was not rounding the values to the nearest
> > integer.
> > Could anyone give me some assistance to what might be the cause? I am
> > not very familiar with configuring MySQL, but have full access to the
> > configuration files etc.
> > Thanks,
> > David

>
> post a description of the table. run this from cmd line:
>
> desc tablename;
>
> and post the results.
>
> --
> POST BY: lark with PHP News Reader ;o)- Hide quoted text -
>
> - Show quoted text -


I did get my problem resolved, ended up just changing my php
programming mysql queries to not use convert, and took care of
changing to decimal in php instead. The value and value2 columns are
blob types in the production table, but it had previously worked with
the convert to decimal without rounding them on the old server, which
was puzzling. but since I have a work around that works, all is well.

Thanks!

Reply With Quote
  #4 (permalink)  
Old 10-18-2007
Luuk
 
Posts: n/a
Default Re: CONVERT DECIMAL rounding


"dkruger" <davidkruger@techie.com> schreef in bericht
news:1192654309.986558.143930@z24g2000prh.googlegr oups.com...
> On Oct 17, 3:15 pm, lark <ham...@sbcglobal.net> wrote:
>> == Quote from dkruger (davidkru...@techie.com)'s article
>>
>>
>>
>>
>>
>> > Hi Everyone,
>> > I am having a problem with mysql, when using convert. I have version
>> > 5.0.45 of mysql, the problem I am having is if I run a query as
>> > follows, after the insert queries:
>> > insert into testing (value,value2) values ('3.68','7.22');
>> > insert into testing (value,value2) values ('1.21','5.79');
>> > select convert(value,DECIMAL),convert(value2,DECIMAL) FROM testing;
>> > I get the following, where I would expect to get the same values that
>> > were entered with the insert query commands:
>> > +------------------------+-------------------------+
>> > | convert(value,DECIMAL) | convert(value2,DECIMAL) |
>> > +------------------------+-------------------------+
>> > | 1 | 6 |
>> > | 4 | 7 |
>> > +------------------------+-------------------------+
>> > 2 rows in set (0.00 sec)
>> > I am having this problem after moving the production database to this
>> > new server, where the old was not rounding the values to the nearest
>> > integer.
>> > Could anyone give me some assistance to what might be the cause? I am
>> > not very familiar with configuring MySQL, but have full access to the
>> > configuration files etc.
>> > Thanks,
>> > David

>>
>> post a description of the table. run this from cmd line:
>>
>> desc tablename;
>>
>> and post the results.
>>
>> --
>> POST BY: lark with PHP News Reader ;o)- Hide quoted text -
>>
>> - Show quoted text -

>
> I did get my problem resolved, ended up just changing my php
> programming mysql queries to not use convert, and took care of
> changing to decimal in php instead. The value and value2 columns are
> blob types in the production table, but it had previously worked with
> the convert to decimal without rounding them on the old server, which
> was puzzling. but since I have a work around that works, all is well.
>
> Thanks!
>



i think the output of:
select 2/3
is different on your 'old server' and your 'production server' ??

i has sometheing to do with the decimail "." or the decimal "," ....(my
guess)


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:27 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0