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 reply to Re: SQL::Statement limit clause with placeholders
by dragonchild
in thread SQL::Statement limit clause with placeholders
by springm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |