[Chicago-talk] Interpolation problem
richard at rushlogistics.com
richard at rushlogistics.com
Wed Sep 30 11:23:57 PDT 2015
Wondering if anyone can lend a hand here. The set of queries below work when I just plug them directly into the MySQL console. However, when I wrap them in perl they fail with SQL errors.
my @rn;
my $q = "set @rn = 0"'; # set row number var for query below in order to be able to iterate as a hash in featadd.tt
$sth = $dbh->prepare($q);
$sth->execute();
# for now in this same subroutine, let's get the sponsorships that these feats match
$q = "SELECT @rn:=@rn+1 AS RN, l.ID FROM logros l WHERE l.ID>?";
$sth = $dbh->prepare($q);
$sth->execute($lid);
my $log_ref = $sth->fetchall_hashref('RN');
I get:
DBD::mysql::st execute failed: 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 '= 0' at line 1 at test_sql.pl line 12.
DBD::mysql::st execute failed: 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 ':=+1 AS RN, l.ID FROM logros l WHERE l.ID>'7'' at line 1 at test_sql.pl line 17.
DBD::mysql::st fetchall_hashref failed: statement contains no result [err was 4 now 2000000000]
Thanks for any help.
More information about the Chicago-talk
mailing list