On 06/12/10 08:54, Jonathan Leffler wrote:
> Two related questions (prompted by a question from people using
> DBD::Informix):
>
> 1. Are there any known problems with $sth->fetchall_arrayref({}, 50);?
> 2. Are there any requirements on a DBD module to make the limit on
> fetchall_arrayref({}, 50) notation work, or is it purely a DBI feature?
>
> Test code:
My results with DBD::ODBC:
> #!/usr/bin/env perl
> use strict;
> use warnings;
> use DBI;
>
> my $dbh = DBI->connect('dbi:Informix:stores', '', '') or die "Horribly 1";
> my $sth = $dbh->prepare(q{SELECT * FROM Elements}) or die "Horribly 2";
> $sth->execute;
>
> #my $res = $sth->fetchall_arrayref; # Works
me too
> #my $res = $sth->fetchall_arrayref({}, 50); # Fails: no data
works for me
> #my $res = $sth->fetchall_arrayref([], 50); # Fails: no data
works for me
> #my $res = $sth->fetchall_arrayref([0,1,2]); # Works
me too
> my $res = $sth->fetchall_arrayref([0,1,2], 50); # Fails: no data
works for me
> #my $res = $sth->fetchall_arrayref({}); # Works
me too
> #my $res = $sth->fetchall_arrayref(undef, 50); # Fails: no data
works for me
> foreach my $row (@{$res})
> {
> # Use this section for printing arrays
> foreach my $value (@{$row})
> {
> printf "%s ", $value;
> }
> print "\n";
> # Use this section for printing hashes
> #foreach my $key (sort keys %{$row})
> #{
> # printf "%-15s = %s\n", $key, $row->{$key};
> #}
> }
>
> $dbh->disconnect;
>
I get "The disconnect invalidates 1 active statement" which is easily fixed by
adding a $sth->finish before disconnect and results from more rows being
available.
> Choose your own driver and database, etc; choose your own table (my table of
> elements has entries for hydrogen through ununoctium - 1..118; 50 is about
> half the table). It seems that fetchall_arrayref() works fine with no
> arguments and with slice arguments, but none of the slice versions with a
> maximum count does anything.
>
> Am I missing something? Or is there a bug?
>
> Perl 5.13.4 on MacOS X 10.6.5; DBI 1.615, DBD::Informix 2008.0513.
>
Seems to work for me so I don't see a bug.
I was using 1.611 but I upgraded to the trunk and got the same results.
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com