Found a DBD that causes the problem. The attached test script is fine using
DBD::ODBC or DBD:ADO but not with DBD::ASAny (to the same datasource) - an
explicit $sth->finish is required with DBD::ASAny:
DBI::db=HASH(0x1cd674c)->disconnect invalidates 1 active statement handle
(either destroy statement handles or call finish on them before disconnecting)
at D:\perl\dbi_access.pl line 38.
--
Simon Oliver
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
my $dsn = 'DSN=mydb';
my $dbd = 'ASAny';
my $uid = '';
my $pwd = '';
my $attr = {
PrintError => 0,
RaiseError => 1,
LongTruncOk => 1,
};
my $dbh = DBI->connect("dbi:$dbd:$dsn", $uid, $pwd, $attr) or
die "Error: Connecting to datasource";
my $sql = q{select * from mytable};
print qq{$dsn -> "$sql"\n\n};
my $sth = $dbh->prepare($sql);
$sth->execute;
while (my $dataref = $sth->fetchrow_hashref){
while (my ($col, $val) = each %{$dataref}) {
my $val = $dataref->{$col};
$val = '[null]' if !defined $val;
print "\t$col => $val\n";
}
print "\n";
}
#$sth->finish;
$dbh->disconnect;