in reply to Multiple Updates with SQL in one connection
You don't mention whether you have AutoCommit set, but this is a common error when it's not. You might want to try something like this, assuming the data you want to update are arrayrefs in @data:
$dbh->{RaiseError} = 1; # if not already my $sql = "UPDATE $table SET X = ? WHERE Y = ?"; my $sth = $dbh->prepare( $sql ); eval { foreach my $d ( @data ) { $sth->execute( $d->[0], $d->[1] ); } }; if ( $@ ) { print "Caught error: $@\nRolling back.\n"; $dbh->rollback; } else { $dbh->commit; }
Chris
M-x auto-bs-mode
|
|---|