Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
these are mostly SQL questions, not Perl.

Well ... to get you started with DBI

> then how can i run the query continuously

->fetchrow will give you row after row if you don't LIMIT you can run it in a loop

> skip to next row if the previous one status eq to no

  • either you select status too and decide in Perl to go to the next loop iteration
  • or if no action is needed you insert a where clause WHERE status == "yes"

I recommend you use DBI#fetchrow_hashref

Fetches the next row of data and returns it as a reference to a hash containing field name and field value pairs. ...

If there are no more rows or if an error occurs, then fetchrow_hashref returns an undef

something like

my $query = $dbh->prepare("SELECT * FROM items ORDER BY created ASC"); + $query->execute(); while ( my $h_fields = $query->fetchrow_hashref() ) { next if $h_fields->{status} eq 'no'; # not needed w +ith WHERE clause ... }


Please see SQL tutorials


) uhm ... DBI has no fetchrow! But ...

$ary_ref = $sth->fetchrow_arrayref; $ary_ref = $sth->fetch; # alias

down-voted for showing wrong code. (Again)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

In reply to Re: checking mysql rows continuously by LanX
in thread checking mysql rows continuously by bigup401

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (2)
    As of 2021-05-08 11:41 GMT
    Find Nodes?
      Voting Booth?
      Perl 7 will be out ...

      Results (96 votes). Check out past polls.