I just ran an example by my co-worker, thinking it would be very easy.
However, I've never used these modules before and it really bombed. I'm
trying a simple SQL query to return the total number of rows in an Oracle
database before printing each one. Here's the small program. Error message
at __END__.

#####

$dbh = DBI->connect("dbi:Oracle:$dbname",$user,$passwd) || die "Error
opening database: $DBI::errstr\n";
$sth = $dbh->prepare("SELECT * FROM table") || die "Prepare failed:
$DBI::errstr\n";

$sth->execute() || die "Couldn't execute query: $DBI::errstr\n";

my $matches = $sth->rows();
unless ($matches) {
        print "Sorry, there are no matches.\n";
} else {
        print "$matches matches found:\n";
        while (my @row = $sth->fetchrow_array) {
                print "@row\n";
        }
}

$sth->finish();
$dbh->disconnect || die "Failed to disconnect\n";

exit();

__END__

###Errors Reported:
$h->rows count is incomplete before all rows fetched.
Sorry, there are no matches.

Any help is appreciated. I've searched perldoc for both DBI and DBD::Oracle,
but nothing addresses the the row function not working as I thought it
would. I just want the total number of rows.

thanks heaps,
Steven

Reply via email to