我正在尝试执行以下脚本:
#!/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具有以下格式:带时区的时间戳NOT NULL默认CURRENT_TIMESTAMP)
问题是没有检测到问号占位符,因为它的内部单引号:
DBD::Pg::st execute Failed: called with 1 bind variables when 0 are needed
如果我使用qq {},$1占位符,并使用$dbh-> quote尝试了一些变体,它无济于事.我怎样才能做到这一点?