Menu

#304 [Perl]When there isn't any records in table, the result of $rows=$dbh-do(select statement) isn't right.

open
nobody
None
5
2012-09-29
2012-09-29
Jira Trac
No

When there isn't any record in one table, run $row=$dbh-do(select * from t1), the result is 0E0.
Repro steps:
{noformat}
use vars qw($db $port $hostname);
$db=$ARGV[0];
$port=$ARGV[1];
my $user=dba;
my $pass=;

my $data_source=dbi:cubrid:database=$db;host=localhost;port=$port;
my $dbh;
$dbh=DBI-connect($data_source, $user, $pass,{PrintError = 1, RaiseError=0}) or warn($DBI::errstr);
$dbh - do(drop table if EXISTS t1;) or warn(drop error: $DBI::errstr);
$dbh - do(create table t1(id int,a string);) or warn(create error: $DBI::errstr);

my $sel_sql=select * from t1;
my $rows=$dbh-do($sel_sql) or warn(Cannot delete all: $DBI::errstr);
print *****rows=.$rows.\n;
is($rows,0,has deleted all);

done_testing();
$dbh - disconnect();
{noformat}

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.