in reply to Problem Converting SQL term to Perl Variable
Or, the best way as can be found in the excellent manual of DBI is to use a placeholder (the ? mark).my $sql = "SELECT Symbol FROM gene_info RIGHT JOIN gene2go ON(gene_inf +o.GeneID=gene2go.GeneID) WHERE GO_Term='$go_term'";
Then you don't need to worry about quoting anymore. Oh, another thing. Get used to use single quote on plain string, e.g it doesn't contain variable or evaluable expression.my $go_term = 'proteasome localization'; my $sql = 'SELECT Symbol FROM gene_info RIGHT JOIN gene2go ON(gene_inf +o.GeneID= gene2go.GeneID) WHERE GO_Term=?'; my $sth = $dbh->prepare($sql); $sth->execute($go_term) or die "SQL Error: $DBI::errstr\n";
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
|
|---|