monkfan has asked for the wisdom of the Perl Monks concerning the following question:
But when I run this Perl script:mysql> SELECT Symbol FROM gene_info RIGHT JOIN gene2go ON(gene_info.`G +eneID`= gene2go.`GeneID`) WHERE GO_Term='proteasome localization'; +-------------+ | Symbol | +-------------+ | SPBC1734.06 | | SPBC646.09c | | cut8 | | rhp6 | | SPAC1420.03 | | SPAC3G6.02 | | rpn5-b | | SPBC19C7.02 | +-------------+ 8 rows in set (2 min 19.11 sec)
It gives:use strict; use Data::Dumper; use Carp; use DBI; my $dsn = 'localhost'; my $user = 'ewijaya'; my $password = 'ewijaya'; my $dbh = DBI->connect('dbi:mysql:motif_finder','monkfan','monkpwd') or die "Connection Error: $DBI::errstr\n"; 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=$go_term"; my $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; while ( my @row = $sth->fetchrow_array ) { print "@row\n"; }
How can we correctly assign SQL command in the Perl Script?:!perl search_gene.pl DBD::mysql::st execute failed: You have an error in your SQL syntax; c +heck the manual that corresponds to your MySQL server version for the + right syntax to use near 'localization' at line 1 at search_gene.pl +line 21. SQL Error: You have an error in your SQL syntax; check the manual that + corresponds to your MySQL server version for the right syntax to use + near 'localization' at line 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem Converting SQL term to Perl Variable
by naikonta (Curate) on Apr 23, 2007 at 05:42 UTC | |
|
Re: Problem Converting SQL term to Perl Variable
by jeanluca (Deacon) on Apr 23, 2007 at 05:42 UTC | |
|
Re: Problem Converting SQL term to Perl Variable
by ysth (Canon) on Apr 23, 2007 at 09:08 UTC | |
|
Re: Problem Converting SQL term to Perl Variable
by quester (Vicar) on Apr 23, 2007 at 05:47 UTC |