in reply to Re: Re: DBI/DBD::mysql bugs?
in thread DBI/DBD::mysql bugs?

Can you upgrade to a newer version of DBI ?
The latest one is 1.21, I believe.
The following code works on my Win2K PC (cygwin, PostgreSQL, DBI 1.201, ActivePerl 5.6.1)
use DBD::ODBC; use DBI; my $p = {}; my $t_id = '20'; $p->{P_BATS} = 'R'; $p->{P_THROWS} = 'R'; $p->{P_STATUS} = 'A'; $p->{P_PLAYERID} = 1; my $dbh = DBI->connect('DBI:ODBC:test', 'foo', 'bar', {RaiseError => 1 +}); my $sth = $dbh->prepare(qq/UPDATE players SET t_id=?, bats=?, throws=? +, status=? WHERE id=?/); $sth->execute($t_id, $p->{P_BATS}, $p->{P_THROWS}, $p->{P_STATUS}, $p- +>{P_PLAYERID}); $sth = $dbh->prepare(qq/SELECT * FROM players/); $sth->execute(); while (my @row = $sth->fetchrow_array()){ print join(',', @row),"\n"; } $dbh->disconnect();
Table 'players' is defined as follows
test=# \d players Table "players" Attribute | Type | Modifier -----------+-----------------------+---------- id | integer | t_id | character varying(20) | bats | character varying(20) | throws | character varying(20) | status | character varying(20) |

--perlplexer

Replies are listed 'Best First'.
Re: Re: Re: Re: DBI/DBD::mysql bugs?
by dsb (Chaplain) on Apr 10, 2002 at 02:38 UTC
    We found what we think is the problem.

    At another point I was checking to see if the value is equal to 0 regardless of whether its a string or not(checking all hash elements).

    What seems like is happening is that when the comparison is made the variable is flagged as an integer. Then when DBI gets the variable it still sees the variable as an integer so doesn't quote it.

    if ($p->{P_THROWS} == 0) { # flag as int for numeric comparison # blah } # blah # blah # blah # now when DBI prepares this statement with the bind variable # $p->{P_THROWS} is seen as an int so not quoted. $sth = $dbh->prepare("UPDATE players SET throws=? WHERE id=?");
    So it could be some obscure bug with DBI that doesn't recognize the variable as a string. But we upgraded to the recent version of DBI and the problem still occured. So either we're wrong or the bug hasn't been spotted/fixed.

    We did manage a work around that doesn't involve testing for 0 so the variable is never flagged as an integer.

    Thanks for your help. ;)

    Amel - f.k.a. - kel