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

Discussion in 'Perl Misc' started by Marc Baker, Jan 18, 2006.

  1. Marc Baker

    Marc Baker Guest

    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;
     
    Marc Baker, Jan 18, 2006
    #1
    1. Advertising

  2. Marc Baker

    Guest

    Marc Baker wrote:
    > 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;

    --
    http://DavidFilmer.com
     
    , Jan 18, 2006
    #2
    1. Advertising

  3. Marc Baker

    Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > Marc Baker wrote:
    > > The line that it is failing on is: while(! > $rec_set->EOF) {

    ^
    Where did that | come from?

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

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
     
    Anno Siegel, Jan 19, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kobu
    Replies:
    10
    Views:
    627
    Keith Thompson
    Mar 4, 2005
  2. Nagaraj
    Replies:
    1
    Views:
    876
    Lionel B
    Mar 1, 2007
  3. SpreadTooThin

    ifstream eof not reporting eof?

    SpreadTooThin, Jun 13, 2007, in forum: C++
    Replies:
    10
    Views:
    697
    James Kanze
    Jun 15, 2007
  4. Jan Burse
    Replies:
    67
    Views:
    1,066
    Jan Burse
    Mar 14, 2012
  5. perl Newbie
    Replies:
    2
    Views:
    846
    perl Newbie
    May 6, 2009
Loading...

Share This Page