At 15:02 -0700 5/5/04, [EMAIL PROTECTED] wrote:
before I begin sorry for the cross post but i'm desperate
The routine in question is below. It's pretty straight forward its a
series of loops which basically matches the row then dumps data
stored in hash ref into the DB. for some reason the script runs with
no errors (ran with strict) I can verify that the data is being
iterated, but when I check the Db no data is updated, the int fields
have been updated to 0 as opposed to NULL. is anyone seeing
somethign I'm not.
If you want them set to NULL using DBI, you have to bind undef to the
proper parameter. Is that what you're doing, or are you binding
something else, such as 0 or the empty string?
Have you tried turning on DBI's trace facility to see what's happening?
P.S., you don't need the semicolons at the ends of the query strings.
That's a mysql client thing, but you're not using mysql.
sub write_db_2 {
my ($ar_info,$table) = @_;
my ($dbh,$sth,$k,$rh_row);
$dbh = connect_try("rowan","5340brig");
foreach $k (keys (%{$ar_info->[1]})){
if ($table eq "prop_info"){
$sth = $dbh->prepare ("UPDATE prop_info
SET $k = ?
WHERE prop_str_addr = ?;") or
err_trap("failed to prepare
statement\n");
}elsif ($table eq "own_info"){
$sth = $dbh->prepare ("UPDATE own_info
SET $k = ?
WHERE own_str_addr = ?;") or
err_trap("failed to prepare
statement\n");
}
foreach $rh_row (@$ar_info) {
print "::$k=>$rh_row->{$k}";
$sth->bind_param (1,$rh_row->{$k});
if ($table eq "prop_str_addr") {
$sth->bind_param (2,$rh_row->{prop_str_addr});
}elsif ($table eq "own_str_addr") {
$sth->bind_param (2,$rh_row->{own_str_addr});
}
$sth->execute() or
err_trap("failed to execute statement\n");
}
print "\n===========================\n";
}
$sth->finish();
$dbh->disconnect or
err_trap("failed to disconnect statement\n");
}
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>