Cant' call method "EOF" on an undefined value...

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;
 
U

usenet

Marc said:
The line that it is failing on is: while(! > $rec_set->EOF) {

That's because $rec_set is not defined. Which means either the select
failed, or your earlier connection to the database failed.

You should insert some error-handling when you establish your
connection and submit your select so you can see exactly what failed
and why.

See the "RaiseError" and "PrintError" flags of the "connect" function
and report error messages from operations similar to:

$rows = $dbh->do($statement, \%attr) or die $dbh->errstr;
 
A

Anno Siegel

^
Where did that | come from?

I'm seeing a ">" that wasn't in the original code and would be a
syntax error.

Anno
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top