use strict; use warnings; use Test::More tests => 10; use DBI; my $dbuser = shift @ARGV || 'foo'; my $dbpass = shift @ARGV || 'bar'; my $val = 1679971; my $dbh = DBI->connect ('dbi:mysql:test', $dbuser, $dbpass) or die "Conn error: $DBI::errstr"; ok ($dbh->do('CREATE TABLE foo ( bar FLOAT )'), 'Table created'); try_now ($dbh, $val); $dbh->do ('DROP TABLE foo'); ok ($dbh->do('CREATE TABLE foo ( bar FLOAT (10,0) )'), 'Table created with right precision'); try_now ($dbh, $val); $dbh->do ('DROP TABLE foo'); $dbh->disconnect; sub try_now { my ($dbh, $val) = @_; my $out = 0; ok ($dbh->do('INSERT INTO foo VALUE (?)', undef, $val), 'Value inserted'); ok (my $sth = $dbh->prepare ('SELECT bar FROM foo'), 'Select prepared'); ok ($sth->execute, 'Select executed'); ($out) = $sth->fetchrow_array; is ($val, $out, "Output value $out equals input value $val"); }