Although it's not typical, there are times when I find the use of a limit, without the use of ORDER BY to be very useful--

If you're attempting to get the field that will be returned by a query (typically because of stuff like 'SELECT * FROM table'), adding a limit is useful, but you can also just throw in 'WHERE 0=1'.

If you're attempting to clear a queue of some sort, where it doesn't need to be FIFO or otherwise processed in some particular order, but you can't have it run for too long. (so you can work in 500 record sets, rather than working on the whole queue at once) I found this very useful in Oracle, when I'd have to limit my processing time for each transaction so I didn't exceed my rollback segments as the system tried to maintain transactional consistency. (and unfortunately, due to the nature of the problem, I couldn't just set the transaction SERIALIZABLE ... I might've been able to use a autonomous transaction, though)

So, in most situations, I agree that it doesn't make sense, but there are times when it does, and it probably has more to do with how the programmer thinks about the problem more than anything else -- there are other working solutions for the examples that I've given above, but using limits without ordering in those situations makes sense to me.


In reply to Re^4: SQL::Statement limit clause with placeholders by jhourcle
in thread SQL::Statement limit clause with placeholders by springm

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.