I am currently working on a project which requires reading up 30 Million records from MS SQL by calling a stored proc and process. The following script works for smaller runs, but die without any error/warnings from Perl at about 2.5 Million.

The stored proc has been tested from MS SQL client and it finishes successfully (it takes like 6 hours). I am just wandering if there is something wrong from the following code or is there any parameters in DBI that I should set to make Perl wait for the whole set of records indefinately?

my $cdr_list = {}; eval { my $query = "EXEC prc_getUsage $run_id, 'CDR', '$start_account +', '$end_account'"; print "\t\tpreparing query [$query]\n"; my $sth = $utils->{DBH}->prepare($query); print "\t\texecuting query\n"; $sth->execute(); my $i =1; print "\t\tfetching records\n"; while (my $record = $sth->fetchrow_hashref()) { my $msisdn = $record->{MSISDN}; #print "\t\tfetchrow [$msisdn] [$i]\n"; $i++; unless (defined $cdr_list->{$msisdn}) { $cdr_list->{$msisdn} = []; } push @{$cdr_list->{$msisdn}}, $record; } $sth->finish(); }; print "\t\tCompleted selecting CDRs\n"; if ($@) { # Try to check for connection error if ($@ =~ /(SQL\-28000)|(SQL\-08S01)/) { $utils->log_error("$@\n", $MAXIS_ERROR_DB_CONNECT); $utils->reconnect(); goto RETRY; } else { $utils->log_error("$@\n", $MAXIS_ERROR_SQL); print "Unhandled Exception [$@]\n"; return undef; } }

In reply to Script die without warning while getting result from DBI by wilsonch

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.