in reply to SQL::Statement limit clause with placeholders

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?"