DBI query does not fetch all data

H

Henri Baeyens

Hello,

I'm using DBI and an ODBC driver to get data from an Access database. The
query is executed but only part of the data is fetched. I know that the
database contains over 1500 rows. My query returns only 28 rows.

use DBI;
use strict;
use warnings;


my $dbh = DBI->connect('dbi:ODBC:boutique', {RaiseError => 1} );
my $query;
my $table = "articles";
my @row_array;

$query = $dbh->prepare("SELECT * FROM $table");
$query->execute;

while (@row_array=$query->fetchrow_array) {
foreach my $item (@row_array){
if ($item eq ""){
print qq~ NULL |~;
} else {
print qq~ $item |~;
}
}
}
my $numrows = $query->rows;
print qq~Number of rows fetched: $numrows~;

etc...


There's also the fact that columns are not fetched in the same order as
they are in the source database, but that's a minor problem.


I can't figure it out. Anything I am missing?

H

www.henribaeyens.com
 
K

kappa

Hello,

I'm using DBI and an ODBC driver to get data from an Access database. The
query is executed but only part of the data is fetched. I know that the
database contains over 1500 rows. My query returns only 28 rows.

use DBI;
use strict;
use warnings;

my $dbh = DBI->connect('dbi:ODBC:boutique', {RaiseError => 1} );
my $query;
my $table = "articles";
my @row_array;

$query = $dbh->prepare("SELECT * FROM $table");
$query->execute;

while (@row_array=$query->fetchrow_array) {
   foreach my $item (@row_array){
      if ($item eq ""){
        print qq~ NULL |~;
      } else {
        print qq~ $item |~;
      }
   }}

my $numrows = $query->rows;
print qq~Number of rows fetched: $numrows~;

etc...

There's also the fact that columns are not fetched in the same order as
they are in the source database, but that's a minor problem.

I can't figure it out. Anything I am missing?

H

www.henribaeyens.com

try "select count(*) from table" to be sure!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top