my $row_checker = "select count(col1) from table1 where col1 = ? and col2 = ? and col3 = ?"; $row_checker = $dbh -> prepare($row_checker); # or ... my $updater = $dbh -> prepare(qq{ update table1 set col1 = ?, col2 = ?, col3 = ? where col1 = ? and col2 = ? and col3 = ? });