Error in DBI::SQLite

I was coding to query a SQLite database using Perl::DBI, I have a small code like this:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=db_file", "", "") or die "error in connection\n";
my $sth = $dbh->prepare($sql) or die "cannot prepare SQL\n";
$sth->execute();
while (my @data = $sth->fetchrow_array()) {
#process data
}
$sth->finish;
$dbh->disconnect;
But, every time I execute this script I obtain this warning:
closing dbh with active statement handles .... blah, blah, blah
I double checked the code, the documentation and ran some debug examples, I obtained the expected result, so why this message? Finally, I found the solution in the PerlMonks website, the problem is a bad status return in the module when you use close() method, so the simple solution is to "undef $sth" at the end:
$sth->finish;
undef $sth;
$dbh->disconnect;

Comments

Popular posts from this blog

Ubuntu Cluster - Slave nodes

PS3 cluster