Re: DBI and fetchall_arrayref with max_rows?

Todd Zervas <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <21386138.1291643588064.JavaMail.root@elwamui-royal.atl.sa.earthlink.net>
All work for me on DBD::Unify 0.80.

-----Original Message-----
>From: Jonathan Leffler <[email protected]>
>Sent: Dec 6, 2010 12:54 AM
>To: DBI Developers Mailing List <[email protected]>
>Subject: DBI and fetchall_arrayref with max_rows?
>
>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:
>
>#!/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
>#my $res = $sth->fetchall_arrayref({}, 50);    # Fails: no data
>#my $res = $sth->fetchall_arrayref([], 50);    # Fails: no data
>#my $res = $sth->fetchall_arrayref([0,1,2]);    # Works
>my $res = $sth->fetchall_arrayref([0,1,2], 50);   # Fails: no data
>#my $res = $sth->fetchall_arrayref({});    # Works
>#my $res = $sth->fetchall_arrayref(undef, 50);  # Fails: no data
>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;
>
>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.
>
>-- 
>Jonathan Leffler <[email protected]>  #include <disclaimer.h>
>Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
>"Blessed are we who can laugh at ourselves, for we shall never cease to be
>amused."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.