On Sunday 26 March 2006 18:58, Stephen Day wrote:
> I have perl, v5.8.7 built for i686-linux running on gentoo.
> I've installed the DBI::AnyData modules ( DBI, SQL::Statement, DBD::CSV,
> AnyData, DBD::AnyData ) with perl -e  'use CPAN; install  <whatever>'
>
> I have the following script more or less copied from the CPAN example:
> -- Start
> #!/usr/bin/perl
> use DBI;
>
> my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');
>     $dbh->func( 'users', 'Passwd', '/etc/passwd', 'ad_catalog');
>     my $sth = $dbh->prepare("SELECT username FROM users");
> $sth->execute();
>
> while (my $row = $sth->fetch) {
>         print "@$row\n";
> }
>
> $sth->finish();
> $dbh->disconnect();
> -- End
>
> The script works ( lists all usernames from /etc/passwd ) but always
> returns the following warning at the end:
>
> DBI handle 0x8529630 cleared whilst still active.
>     dbih_clearcom (sth 0x8529630, com 0x85452e8, imp DBD::AnyData::st):
>        FLAGS 0x182195: COMSET Active Warn RaiseError PrintError PrintWarn
> ShowErrorStatement
>        PARENT DBI::db=HASH(0x8529504)
>        KIDS 0 (0 Active)
>        IMP_DATA undef
>        NUM_OF_FIELDS 1
>        NUM_OF_PARAMS 0
>
> The only help I can find on google says do '$sth->finish()', Well I did and
> it didn't help.
>
>
> Any idea what is going wrong here?
>
>
> Stephen

A clearer example of this is as follows:

--Start script
#!/usr/bin/perl
use DBI;

my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');
$dbh->func('mytable','CSV','data.csv','ad_catalog');
my $sth = $dbh->prepare("SELECT some FROM mytable");

$sth->execute();

while ( my $row = $sth->fetch ) {
  print "@$row\n";
}

$sth->finish();
$dbh->disconnect();
-- End

--Start data.csv
some,csv,data,not,a,lot,but,enough,to,test,with
some1,csv1,data1,not1,a1,lot1,but1,enough1,to1,test1,with1
some2,csv2,data2,not2,a2,lot2,but2,enough2,to2,test2,with2
some3,csv3,data3,not3,a3,lot3,but3,enough3,to3,test3,with3
--End

Result:
$ ./t1.pl
some1
some2
some3
DBI handle 0x85fa9dc cleared whilst still active.
    dbih_clearcom (sth 0x85fa9dc, com 0x85fbb48, imp DBD::AnyData::st):
       FLAGS 0x182195: COMSET Active Warn RaiseError PrintError PrintWarn 
ShowErrorStatement
       PARENT DBI::db=HASH(0x85fa8b0)
       KIDS 0 (0 Active)
       IMP_DATA undef
       NUM_OF_FIELDS 1
       NUM_OF_PARAMS 0


Stephen

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to