- 论坛徽章:
- 0
|
回复 #2 DQP 的帖子
这个是SQL语句,可能我没有说清楚,我想在perl里实现这个,我的perl是这样写的:
use DBI;
use strict;
my $dbh = DBI->connect($dsn,$user,$passwd,{RaiseError=>1});
my $sth = $dbh->prepare("SELECT id FROM table1 WHERE id='orange") or
die("Cannot prepare statement:",$dbh->errstr(),"\n");
$sth->execute() or die("Cannot execute statement:",$sth->errstr(),"\n");
if ($sth) {
my $ref = $sth->fetchrow_array;
print "$ref\n";
}
else {
print "orange is not exist.\n";
}
$sth->finish();
$dbh->disconnect();
运行后的结果应该是输出: orange is not exist.
可实际的结果是空的,什么都没有。
还是我这样写不对呢? |
|