my $sql = <<'END'; select the_data from my_table where filter1 = ? and filter2 = ? END # dbh is my database handle, already connected here my $sth = $dbh->prepare($sql); $sth->execute( $bind_val_1, $bind_val_2 ); # this line throws my error my $data = $sth->fetchall_arrayref; #### my $sql = <<'END'; select the_data from my_table where filter1 = $bind_val_1 and filter2 = $bind_val_2 END # dbh is my database handle, already connected here my $sth = $dbh->prepare($sql); $sth->execute; # This line now completes successfully my $data = $sth->fetchall_arrayref;