in reply to Re: Re: DBI::fetchall_arrayref() error
in thread DBI::fetchall_arrayref() error
#!C:/Perl/bin/perl use strict; use DBI; use DBD::Sybase; use Data::Dumper; my $dbh = DBI->connect("dbi:Sybase:server=SERVER;database=DATABASE", + "USER","PASSWORD") or die "Can not connect to database!"; my $sth = $dbh->prepare( qq{ select amount from trades_gdw_total }); $sth->execute(); while (my $rows = $sth->fetchall_arrayref([0], 3)) { last if ($#$rows <= 0); for (@$rows) { print "got @$_\n"; } print "---\n"; }
# we copy the array here because fetch (currently) always # returns the same array ref. XXX if ($slice && @$slice) { # if called with [0] $max_rows = -1 unless defined $max_rows; push @rows, [ @{$row}[ @$slice] ] while($max_rows-- and $row = $sth->fetch); } elsif (defined $max_rows) { # if called with undef $max_rows = -1 unless defined $max_rows; push @rows, [ @$row ] while($max_rows-- and $row = $sth->fetch); } else { push @rows, [ @$row ] while($row = $sth->fetch); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: DBI::fetchall_arrayref() error
by pg (Canon) on Jan 12, 2004 at 03:02 UTC |