#!/perl/bin/perl use strict; use warnings; use Data::Dumper; use SQL::Abstract; my %fd = ( txtName => 'OK', txtCreated => '', txtDateren => '', # will use NOW() function txtOldname => 'NOT OK', txtDel => '', ); my $id = 1234; # column name mapping my %cols = ( txtName => 'Listname', txtCreated => 'DateCreated', txtDateren => 'DateRenamed', txtOldname => 'OldListname', txtDel => 'DateDeleted', ); # which column to update? my %column = map { $cols{$_} => $fd{$_} } grep { $fd{$_} } keys %fd; $column{DateRenamed} = \'NOW()'; my $sql = SQL::Abstract->new; my($query, @binds) = $sql->update('table', \%column, { id => id }); print Data::Dumper::Dumper($query, \@binds); #### $VAR1 = 'UPDATE table SET DateRenamed = NOW(), Listname = ?, OldListname = ? WHERE ( id = ? )'; $VAR2 = [ 'OK', 'NOT OK', 1234 ];