Hi Tim

The data's definitely wrong - eg "select concat('fred', t1) from test gives "fred0.44". I first noticed the problem printing eg $r->[1] from a fetch in Perl. It comes out the same either to STDOUT or on a Web page.

Robbie

From: Tim Bunce <[EMAIL PROTECTED]>
To: Robbie Armour <[EMAIL PROTECTED]>
CC: [EMAIL PROTECTED]
Subject: Re: Rounding errors storing numbers in MySQL text fields using DBI
Date: Tue, 24 Jun 2003 12:16:20 +0100

On Tue, Jun 24, 2003 at 03:23:08AM +0100, Robbie Armour wrote:
> $qst = $dbh->prepare("insert into test (t1) values (?)");
> $qst->execute(0.4444);
> $qst->execute('0.3333');
>      Binding parameters: insert into test (t1) values (0.4444)
>      Binding parameters: insert into test (t1) values (0.3333)
>
> mysql> select * from test;
> +------+
> | t1   |
> +------+
> | 0.44 |
> | 0.33 |
> +------+
>
> My guess from a scan through the DBI man page is that it's some kind of
> typeinfo thing (I'm floundering now)?

My guess is that the DBI and DBD::mysql is working just fine, and
the the mysql command line client is 'helpfully' presenting the
values with just two decimal places. I think you'll find the data is fine.

Tim.

_________________________________________________________________
Sign-up for a FREE BT Broadband connection today! http://www.msn.co.uk/specials/btbroadband




Reply via email to