I am programming perl for a while now but mysql, and the combination of perl with mysql is very new to me. I wrote a perl script that is supposed to do kmedoids-clustering of several thousand promoters (human genome).

Many instances of this script are running on a Grid Engine cluster. When I run this script with a random selection of a few hundred promoters only, everything works fine.

But now I tried to cluster the full dataset of several thousand promoters and get this error:

"DBD::mysql::st fetchrow_array failed: fetch() without execute() at chipchip.pl line 144, <L3> line 14446. "

Here is the part of my script where it happens, I think:

foreach $item (@{$clusters}) { $ID = $units[$i][0]; $query = "select * from finalLevel3 where id=\"$ID\";"; $sth = $dbh -> prepare($query); $sth -> execute; @row = $sth -> fetchrow_array; # convert the mysql result back to a string again $promoter_line = join "\t", @row; $promoter_line .= "\n"; $parser_hash{$item} .= $promoter_line; $i++; }

I found a thread in this forum which I think is a very similar problem and the solution, however I must say that I simply don't understand how to solve this and what's going on. That thread is node 729564. I'm happy that this problem seems already to be solved but I simply don't understand the solution - a more verbose explanation would be very, very much appreciated.

Do I need two separate $dbh - handles? If yes do I need to connect them separatedly?

I would be very thankful if someone could explain to me how to fix this. Also, the thing is that this error only shows up if I do the clustering on the whole dataset (2 days runtime on Grid Engine), so it would be superduper cool if I could get it right the first or second time because it takes so long to reproduce the error. Thank you.


In reply to perl, mysql: "fetchrow_array failed: fetch() without execute()" by gojira

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.