【发布时间】:2015-05-11 01:55:16
【问题描述】:
我正在使用 Perl DBI/PostgreSQL,我想检索列中的最小值,但我收到以下代码的“在连接 (.) 或字符串中使用未初始化的值 $id”消息:
my $id = 0;
$sth = $dbh->prepare("
select min(col_id)
from table
where col_num = x
") or die $dbh->errstr;
$sth->execute() or die $dbh->errstr;
while (my $results = $sth->fetchrow_hashref) {
$id = $results->{col_id};
}
print "$id";
它在 postgresql 编辑器中有效,但在 perl 中无效。任何帮助将不胜感激!
【问题讨论】:
标签: perl postgresql dbi