perl fetchrow_array重新返回一个空数组
嘿,我编码一个需要从数据库获取数据的Perl脚本。但是,当我获得返回值时,它的阵列又回到了一个阵列,所以我将其解释。但是它仍然什么也没打印。我在sqlplus上运行了命令,它在那里毫无问题地工作。我不确定如何求解此
代码:
my $sth = $dbh->prepare("select XMLRECORD from F_COMPANY") or
die "Couldnt prepare statement: " . $dbh->errstr;
$sth->execute();
# loop through the returned data
while( my ($row) = $sth->fetchrow_array()){
print "@$row\n";
}
输出:实际上没有
Hey Im coding a perl script which needs to get data from a database. But when I get a return value its comes back in an array so i dereference it. Yet it still prints out nothing. I ran the command in sqlplus and it worked there without issue. Im not sure how to solve this
Code:
my $sth = $dbh->prepare("select XMLRECORD from F_COMPANY") or
die "Couldnt prepare statement: " . $dbh->errstr;
$sth->execute();
# loop through the returned data
while( my ($row) = $sth->fetchrow_array()){
print "@$row\n";
}
OUTPUT: Literally nothing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
始终使用
使用严格;使用警告;
。它会遇到您的错误。fetchrow_array
不返回数组引用。它将行的值返回单个标量。您想要
或
输出:
ALWAYS use
use strict; use warnings;
. It would have caught your error.fetchrow_array
does NOT return an array reference. It returns the values of the row as individual scalars.You want
or
Output: