perl中DBI模块中的SQL错误
perl中DBI模块中的SQL错误,sql,perl,module,dbi,Sql,Perl,Module,Dbi,运行此查询时,我没有得到任何输出。我想不出来,有人能帮我吗$在这种情况下,lastfiscyear=09/10 getitem44(); sub getitem44() { $sqlquery = sprintf("select sum(f.expenditure) from funds f,ledger l where l.ledger_id in (select l
运行此查询时,我没有得到任何输出。我想不出来,有人能帮我吗$在这种情况下,lastfiscyear=09/10
getitem44();
sub getitem44()
{
$sqlquery = sprintf("select sum(f.expenditure)
from funds f,ledger l
where l.ledger_id in (select ledger_id from ledger
where upper(ledger_name) like 'MONOACQ%' and
substr(ledger_name,length(ledger_name)-4, 5) = '%s') and
f.ledger_id = l.ledger_id and
substr(f.funds_name, 1, instr(f.funds_name,',')-1) like '%e' ", $lastfiscyear);
$sth = $dbh->prepare($sqlquery);
$rc = $sth->execute;
my $total = $sth->fetchrow_array;
print "$total\n";
}
您需要用一个额外的百分号转义
%e
,否则sprintf
将其解释为转换说明符(科学记数法中的浮点数)
有关详细信息,请参见。您需要使用附加的百分号转义
%e
,否则sprintf
将其解释为转换说明符(科学记数法中的浮点数)
有关详细信息,请参见。请注意,
sprintf
将使用%
符号作为占位符。如果要将逐字%
放入字符串,请将其加倍。我认为问题是%e
接近尾声-它被0.000000e+000
替换。请注意sprintf
将使用%
符号作为占位符。如果要将逐字%
放入字符串,请将其加倍。我想问题是%e
接近尾声了-它被0.000000e+000
取代了。非常感谢你的“eugene y”。非常感谢你的“eugene y”。感谢“bvr”的解释。感谢“bvr”的解释。非常感谢你的帮助。非常感谢你的帮助。
sprintf "select sum(f.expenditure) ... like '%%e' ", $lastfiscyear;