我正在尝试执行以下脚本:
#!/usr/bin/perl -w
use strict;
use DBI;
my $db = "Pg";
my $db_database = "whatever";
my $user = "whatever";
my $password = "whatever";
my $dbh = DBI->connect("dbi:$db:dbname=$db_database", $user, $password);
my $query = $dbh->prepare (q{SELECT
arrival_date - INTERVAL '? MINUTE'
FROM emails LIMIT 1})
or die ("unable to prepare");
$query->execute(60) or die("unable to execute");
print $query->fetchrow_array, "\n";
(arrival_date 有这种格式:time zone NOT NULL default CURRENT_TIMESTAMP 的时间戳)
问题是未检测到问号占位符,因为它在单引号内:
DBD::Pg::st execute failed: called with 1 bind variables when 0 are needed
如果我使用 qq{}、$1 占位符并尝试使用 $dbh->quote 的一些变体,这将无济于事。我怎样才能使这项工作?