use Win32::ODBC; use Data::Dumper; use strict; my $Data = new Win32::ODBC("myDSN") || die "failed\n"; $Data->Run("DROP TABLE test1"); $Data->Run('CREATE TABLE test1(a number, b char(1))'); for (1..50) { my $statement = "INSERT INTO test1 VALUES($_, ' ')"; $Data->Run($statement); } $Data->Sql("SELECT * FROM test1"); while (1) { my @Rows = FetchRows($Data, 4);#fetch 4 rows each time print Dumper(\@Rows); last if $Rows[0];#$Rows[0] is used to indicate whether we reached the end of active dataset } sub FetchRows { my ($Connection, $Rows) = @_; my @Rows; push @Rows, 0; # for (1..$Rows) { if ($Data->FetchRow()) { my %hash = $Data->DataHash(); push @Rows, \%hash; } else { $Rows[0] = 1; } } return @Rows; }