I would suggest having a table with an autoincrement field, so your query would be
SELECT * FROM table ORDER BY row LIMIT x;
where x is how many lines you want to process...

To handle row locking you could add a status field, and then do your insert, anything else you need to do, then do an
UPDATE table SET status = 1 WHERE row = LAST_INSERT_ID();
and then change the select to check for status = 1...
but I think as long as your insert is only a single simple insert that it is not a problem...

Update bad suaveant, didn't read the post right... use the row id from autoincrement to key into your second table, and then do the update to set the status = 1 in the main table... that should do you good. So do main insert, then
SELECT LAST_INSERT_ID() FROM table1;
and use that key to populate table2 with the proper key, then
UPDATE table SET status = 1 WHERE key = $key;

Should work great

                - Ant


In reply to Re: Queues, not the usual problem by suaveant
in thread Queues, not the usual problem by rob_smith01

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.