August 14th, 2013, 08:37 AM
-
Give us a hint. What was expected, what happened? Were there error messages?
I did notice that even though all results were fetched in this line:
Code:
my $employees = $sth->fetchall_arrayref({});
you attempted to fetch again:
Code:
while ( my @row = $sth->fetchrow_array( ) ) {
print $csv->print($FILE, \@row);
}
If the first fetch is working (that's what Data::Dumper is for), then just use those results by looping over the array.
August 14th, 2013, 09:35 AM
-
From the DBI module documentation:
The fetchall_arrayref method can be used to fetch all the data to be returned from a prepared and executed statement handle. It returns a reference to an array that contains one reference per row.
Thus, when you do this:
Perl Code:
my $employees = $sth->fetchall_arrayref({});
$employee is now a ref to an array containing references to all of your data rows.