PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > CONVERT DECIMAL rounding
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
CONVERT DECIMAL rounding

Réponse
 
LinkBack Outils de la discussion
Vieux 17/10/2007, 17h04   #1
dkruger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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

  Réponse avec citation
Vieux 17/10/2007, 22h15   #2
lark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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)
  Réponse avec citation
Vieux 17/10/2007, 22h51   #3
dkruger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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!

  Réponse avec citation
Vieux 18/10/2007, 09h28   #4
Luuk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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)


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h14.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11970 seconds with 12 queries