[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] DBH statement isn't closing




On Sep 19, 2006, at 2:52 PM, Mike Hostetler wrote:
I'm mucking around with DBI stuff for the first time.

Welcome to the fray! -laugh-

I thought I did everything right, but I guess I didn't.

Here is my code:
===============
#!/usr/bin/perl -w

use DBI;

Huh. I'm surprised DBD::SQLite docs say to 'use DBI;'. I would have thought they would say to 'use SQLite;'. Oh well, no matter.

my $cacheDB = DBI->connect("dbi:SQLite:waypoint.db","","") or die "Couldn't fin\
d cache database";

my $stmt = $cacheDB->prepare("Select lat,lon from waypoint where name=?");

$stmt->execute( ("Home") );
my ($lat,$lon);

$stmt->bind_columns(undef,\$lat,\$lon);

What does that undef do? Try removing that.

while ($stmt->fetch() ) {
  print "$lat\t$lon\n";
}

$stmt->finish();
$cacheDB->disconnect();
==========

I get the correct output, but I also get this warning:

closing dbh with active statement handles at dberror.pl line 19.

I thought I did close it with the finish method.  Maybe I didn't.

I agree with you. Maybe that undef is doing something weird?

Many, many, many DBI gurus hang out here:
http://lists.cpan.org/showlist.cgi?name=dbi-users

They might know.

Are your versions of DBD::SQLite and DBI current?

   perl -MDBI -e 'DBI->installed_versions'

j