sub UpdateFromHash { my $DBH = $_[0] or &FatalError('DBx0001'); my %Fields = %{$_[1]} or &FatalError('DBx0006',['Fields']); my $Table = $_[2] or &FatalError('DBx0006',['Table']); my @Conds = @{$_[3]} or &FatalError('DBx0006',['Conditions']); my $Limit = $_[4]; my $Statement; $Statement = 'UPDATE '.$Table.' SET '.join (', ',&{sub{my @f;push @f, "$_ = ".$DBH->quote($Fields{$_}) for (keys(%Fields));return @f;}}). ' WHERE '.join (' AND ',@Conds).($Limit?" LIMIT $Limit":"").';'; if ($DBH->do($Statement)) { return 1; } else { &FatalError('DBx0007', [$Statement, $DBH->errstr()]); } }