I don't see any reason for your code to hang in this snippet. Maybe you can optimize it a bit, as in the example below, but there is nothing so wrong that it could cause a halt.

sub fetchRowArray($$){ my $dbh = shift; my $sql = shift; my $sth = $dbh->prepare($sql) or die("statement can't be prepared"); $sth->execute() or die("Statement can't be executed"); my $columnNames = $sth->{NAME}; my $numfields= $sth->{NUM_OF_FIELDS}; my $matrix) = $sth->fetchall_arrayref(); return $matrix, $columnNames, $numfields; }

What is not clear in your request is this: you say that your code stops after 17 loops and later that the MySQL log shows 17 queries. Therefore, maybe the reason for hanging is not in this loop, but some other place in your script.

The candidates for further scrutiny are, then, your sub meldeFehler and the point from where your are calling fetchRowArray.

Please clarify what you mean by loop. If you mean that it hangs after 17 successful queries, then you may have a memory problem. If you mean that it hangs when the records are more than 17, then I don't see the cause here.

As a piece of practical advice, I would recommend to run this script from the command line, to see if the result is what you expected, and put some print statements in the critical points (printing, for example, "inside meldeFehler", "before calling fetchRowArray", and so on) so that you get a clear idea of where exactly the code stops.

HTH


In reply to Re: Re: mysql perl hangs on selects by dbwiz
in thread mysql perl hangs on selects by Murcia

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.