The immediate source of your problem is that SQL::Parser (the parser used by SQL::Statement) has the following subroutine:
sub LIMIT_CLAUSE { my($self,$limit_clause) = @_; # $limit_clause = trim($limit_clause); $limit_clause =~ s/^\s+//; $limit_clause =~ s/\s+$//; return 1 if !$limit_clause; my($offset,$limit,$junk) = split /,/, $limit_clause; return $self->do_err('Bad limit clause!') if (defined $limit and $limit =~ /[^\d]/) or ( defined $offset and $offset =~ /[^\d]/ ) or defined $junk; if (defined $offset and !defined $limit) { $limit = $offset; undef $offset; } $self->{"struct"}->{"limit_clause"} = { limit => $limit, offset => $offset, }; return 1; }

The important part is the middle. SQL::Parser demands that all parameters to a LIMIT clause be numeric. This is inline with most (but not all) DBD::'s. The major exception is DBD::mysql, which allows parameters in LIMIT clauses (with certain restrictions).

If you feel that this is a useful feature, provide a few test cases for the author. Better is the patch as well, but the test cases are a minimum.


  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

In reply to Re: SQL::Statement limit clause with placeholders by dragonchild
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.