LIMIT with placeholder

[prev] [thread] [next] [Date index for 2004/06/10]

From: Gabor Szabo
Subject: LIMIT with placeholder
Date: 02:47 on 10 Jun 2004
I am probably missing something obvious here, but could not make this
work.


The following works fine:

In the table
__PACKAGE__->set_sql(latest => "SELECT * FROM __TABLE__ LIMIT 10");

the user:
My::Names->search_latest();



but I cannot convince it to take a palace holder instead of the hard
coded 10.

In the table
__PACKAGE__->set_sql(latest => "SELECT * FROM __TABLE__ LIMIT %s");

the user:
My::Names->search_latest(10);


I get this:
My::Names can't SELECT * FROM posts LIMIT : DBD::SQLite::st execute failed: called
with 1 bind variables when 0 are needed [for Statement "SELECT * FROM
names LIMIT "] at /opt/perl584/lib/site_perl/5.8.4/DBIx/ContextualFetch.pm



Replacing %s by ?
__PACKAGE__->set_sql(latest => "SELECT * FROM __TABLE__ LIMIT ?");


I get this:

My::Names can't SELECT * FROM posts LIMIT ?: DBD::SQLite::st
execute failed: near "'10'": syntax error [for Statement "SELECT * FROM
names LIMIT ?"] at
/opt/perl584/lib/site_perl/5.8.4/DBIx/ContextualFetch.pm line 51.




BTW it is not clear (to me) from the documentation if the placeholder
should be %s or ?.



 All this with CDBI 0.96 and SQLite

Gabor

LIMIT with placeholder
Gabor Szabo 02:47 on 10 Jun 2004

Re: LIMIT with placeholder
Tony Bowden 22:01 on 09 Jun 2004

Re: LIMIT with placeholder
Gabor Szabo 16:27 on 10 Jun 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52