When I run this code I get back 3 lines of data regarding different volumes. It's reading some data from a sqlite database.

If I uncomment the $dbh->prepare line I get back only 1 line of data and the loop ends. I cant understand why? It's like the prepare statement is causing the while loop to exit?
# Get a list of volumes that are being monitored and attempt # to get data about them # $sth = $dbh->prepare("SELECT volumeletter,peernodes from VolData order + by volumeid"); $sth->execute(); # Iterate over configured volumes and update status, rrd data and grap +hs while ( my ($vol,$peernodes) = $sth->fetchrow_array() ) { print "\n\n\nVOLUME $vol Peer nodes ($peernodes)\n\n\n"; # Populate a hash with current volume data %voldata = &getVolumeData($vol,$peernodes); # Now, let's update the database with the volumes current stat +e switch ($voldata{'MirrorState'}) { case "0" {$vol_current_state = "Not Mirrored"} case "1" {$vol_current_state = "Mirroring"} case "2" {$vol_current_state = "Resync"} case "3" {$vol_current_state = "Broken"} case "4" {$vol_current_state = "Paused"} case "5" {$vol_current_state = "Resync Pending"} else {$vol_current_state = "Unknown"} } print "COLLECTOR: Setting volume $vol to state $vol_current_st +ate\n"; #$sth = $dbh->prepare("UPDATE VolData SET volstatus = '$vol_cu +rrent_state' WHERE volumeletter = '$vol'"); #$sth->execute(); }

In reply to Why does DBI prepare break my loop? by aditya1977

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.