M
Marc Baker
Hi all,
I'm a newbie here, so bear with my ignorance. I have an existing perl
script that I inherited. Basically, it is erroring out sporadically with
"Can't call method "EOF" on an undefined value at...". The line of code
that it references is doing a SELECT from a MSSQL database. The perl script
is being called from the Microsoft SQL Server Agent. The weird thing is
that this code is not failing all the time, and if I run it manually after
it fails, it will run fine. The data that is being SELECT'ed is static so
nothing is changing from the unsuccessful to a successful run. Below is the
a snippet of the code. The line that it is failing on is: while(!
$rec_set->EOF) {
$rec_set = $conn->Execute("SELECT INVOICES.CLIENT_ID, INVOICES.MATTER_ID,
INVOICES.INVOICE_NO, INVOICES.INVOICE_DATE, IMBAL.INVOICE_ID,
IMBAL.DET_BALANCE, IMBAL.SUM_BALANCE FROM MNT_IMBAL_INVOICE_RECS IMBAL LEFT
OUTER JOIN $MNT_ODS_DB.dbo.INVOICES INVOICES ON INVOICES.ID =
IMBAL.INVOICE_ID WHERE INVOICES.INVOICE_DATE > '1994-12-31 00:00:00' AND
IMBAL.MNT_BAL_REPORT_ID = $id");
print REPORT_FILE sprintf("\n%-78s\n\n", "Invoices whose detail balance
does not agree with their summary balance");
print REPORT_FILE sprintf("%11s %9s %11s %12s %11s %15s %15s\n",
"CLIENT_ID", "MATTER_ID", "INVOICE_NO", "INVOICE_DATE", "INVOICE_ID",
"Detail Balance", "Summary Balance");
my($invoice_id, $det_bal, $sum_bal, $m_matter_id, $m_client_id,
$m_invoice_no, $m_invoice_date);
while(! $rec_set->EOF) {
$m_client_id = $rec_set->Fields('CLIENT_ID')->Value;
$m_matter_id = $rec_set->Fields('MATTER_ID')->Value;
$m_invoice_no = $rec_set->Fields('INVOICE_NO')->Value;
$m_invoice_date = $rec_set->Fields('INVOICE_DATE')->Value;
$invoice_id = $rec_set->Fields('INVOICE_ID')->Value;
$det_bal = $rec_set->Fields('DET_BALANCE')->Value;
$sum_bal = $rec_set->Fields('SUM_BALANCE')->Value;
print REPORT_FILE sprintf("%9s %9s %11s %12s %8s %15s %15s\n",
$m_client_id, $m_matter_id, $m_invoice_no,
$m_invoice_date,
$invoice_id, commify(sprintf("%.2f", $det_bal)),
commify(sprintf("%.2f", $sum_bal)));
$rec_set->MoveNext;
I'm a newbie here, so bear with my ignorance. I have an existing perl
script that I inherited. Basically, it is erroring out sporadically with
"Can't call method "EOF" on an undefined value at...". The line of code
that it references is doing a SELECT from a MSSQL database. The perl script
is being called from the Microsoft SQL Server Agent. The weird thing is
that this code is not failing all the time, and if I run it manually after
it fails, it will run fine. The data that is being SELECT'ed is static so
nothing is changing from the unsuccessful to a successful run. Below is the
a snippet of the code. The line that it is failing on is: while(!
$rec_set->EOF) {
$rec_set = $conn->Execute("SELECT INVOICES.CLIENT_ID, INVOICES.MATTER_ID,
INVOICES.INVOICE_NO, INVOICES.INVOICE_DATE, IMBAL.INVOICE_ID,
IMBAL.DET_BALANCE, IMBAL.SUM_BALANCE FROM MNT_IMBAL_INVOICE_RECS IMBAL LEFT
OUTER JOIN $MNT_ODS_DB.dbo.INVOICES INVOICES ON INVOICES.ID =
IMBAL.INVOICE_ID WHERE INVOICES.INVOICE_DATE > '1994-12-31 00:00:00' AND
IMBAL.MNT_BAL_REPORT_ID = $id");
print REPORT_FILE sprintf("\n%-78s\n\n", "Invoices whose detail balance
does not agree with their summary balance");
print REPORT_FILE sprintf("%11s %9s %11s %12s %11s %15s %15s\n",
"CLIENT_ID", "MATTER_ID", "INVOICE_NO", "INVOICE_DATE", "INVOICE_ID",
"Detail Balance", "Summary Balance");
my($invoice_id, $det_bal, $sum_bal, $m_matter_id, $m_client_id,
$m_invoice_no, $m_invoice_date);
while(! $rec_set->EOF) {
$m_client_id = $rec_set->Fields('CLIENT_ID')->Value;
$m_matter_id = $rec_set->Fields('MATTER_ID')->Value;
$m_invoice_no = $rec_set->Fields('INVOICE_NO')->Value;
$m_invoice_date = $rec_set->Fields('INVOICE_DATE')->Value;
$invoice_id = $rec_set->Fields('INVOICE_ID')->Value;
$det_bal = $rec_set->Fields('DET_BALANCE')->Value;
$sum_bal = $rec_set->Fields('SUM_BALANCE')->Value;
print REPORT_FILE sprintf("%9s %9s %11s %12s %8s %15s %15s\n",
$m_client_id, $m_matter_id, $m_invoice_no,
$m_invoice_date,
$invoice_id, commify(sprintf("%.2f", $det_bal)),
commify(sprintf("%.2f", $sum_bal)));
$rec_set->MoveNext;