my @rows = $sth->fetchrow_array; <--- Reads the first row.
You never print it, though.
Remove this line.
my $rowcount = @rows; <--- Actually, that returns the
number of *fields*, since
@rows actually contains
the first row.
Remove this line.
if ($rowcount > 0) <--- You can't keep this.
You don't even need it.
You could reorganize the
structure to do something
equivalent, but there's
no need for that either.
####
my $dbh = DBI->connect(
"DBI:ODBC:mydsn",
"user",
"password",
{ RaiseError => 0, AutoCommit => 0 }
);
my $sql = "Select * from items where procdate = ?";
my $sth = $dbh->prepare($sql);
or die "\n\n Unable to prepare SQL query: $DBI::errstr\n\n";
$sth->execute($g_date)
or die "\n\n Unable to execute SQL query: $DBI::errstr\n\n";
my (
$seq, $prcdate, $frb, $account, $amount, $check,
$tc, $disp, $run, $batch, $pkt, $catcode, $deviceid,
$volid, $imagefile, $status, $typeid, $bankId,
$itemNumber, $editStatus, $exceptionReasonCode,
$documentId, $postAccount, $appCode, $bundleImageOffset,
$bundleImageLength, $archiveDeviceId, $archiveVolId,
$archiveImageFile, $archiveImageOffset, $archiveImageLength,
$userIdAmountEntry, $AUX, $PC
);
$sth->bind_columns(
undef,
\$seq, \$prcdate, \$frb, \$account, \$amount, \$check,
\$tc, \$disp, \$run, \$batch, \$pkt, \$catcode, \$deviceid,
\$volid, \$imagefile, \$status, \$typeid, \$bankId,
\$itemNumber, \$editStatus, \$exceptionReasonCode,
\$documentId, \$postAccount, \$appCode, \$bundleImageOffset,
\$bundleImageLength, \$archiveDeviceId, \$archiveVolId,
\$archiveImageFile, \$archiveImageOffset, \$archiveImageLength,
\$userIdAmountEntry, \$AUX, \$PC
) or die "\n\n Unable to bind columns: $DBI::errstr\n\n";
while ($sth->fetch()) {
print OUTPUT (
join(',',
$seq, $prcdate, $frb, $account, $amount, $check,
$tc, $disp, $run, $batch, $pkt, $catcode, $deviceid,
$volid, $imagefile, $status, $typeid, $bankId,
$itemNumber, $editStatus, $exceptionReasonCode,
$documentId, $postAccount, $appCode, $bundleImageOffset,
$bundleImageLength, $archiveDeviceId, $archiveVolId,
$archiveImageFile, $archiveImageOffset, $archiveImageLength,
$userIdAmountEntry, $AUX, $PC
), $/
);
}
$sth->finish();
$dbh->disconnect();
####
my $dbh = DBI->connect(
"DBI:ODBC:mydsn",
"user",
"password",
{ RaiseError => 0, AutoCommit => 0 }
);
my $sql = "Select * from items where procdate = ?";
my $sth = $dbh->prepare($sql);
or die "\n\n Unable to prepare SQL query: $DBI::errstr\n\n";
$sth->execute($g_date)
or die "\n\n Unable to execute SQL query: $DBI::errstr\n\n";
my $row;
print OUTPUT (join(',', @$row), $/)
while ($row = $sth->fetch());
$sth->finish();
$dbh->disconnect();