I have a problem with reading a table in an SQL Server database. A script that used to work quite happily, suddenly stopped returning records. The table in question has over 1,006,000 rows, but even when I get Perl to read the whole table, it returns significantly less than a million records. I can see nothing odd about the records in question, nor found any answers to this problem by googling or scouring the DBI docs.
The following is a simple script (names have been changed for confidentiality) that reads the records from just before the problem point to somewhere after. The last record ID read is 968077.
use strict; use DBI; $|=1; my (@row, $e); my$dbh = DBI->connect('DBI:ODBC:dsnname', undef, undef) or die "Couldn't connect to database: " . $DBI::errstr +; $dbh->{'RaiseError'} = 1; my $sql = qq{SELECT * FROM Transaction where TransactionID=?}; my $sth = $dbh->prepare($sql); foreach my $i (968000..1029829) { $sth->execute($i); if (@row = $sth->fetchrow_array()) { print "$row[0], $row[1], $row[2]\n"; } else { print "***** No record for $i *****\n"; $e = $sth->errstr; print " Error: $e\n"; } $sth->finish(); } $dbh->disconnect(); print "\n$0 finished\n\n";

That's so simple it's unlikely to help. Anyone got any clues as to the problem? Any pointers as to what to try next?
All help gratefully appreciated!
Thanks,
Groll.

In reply to DBD::ODBC won't read past a certain record by Groll

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.