note
igelkott
<p>Don't think this can be done with standard DBI. Every substitution gets quoted so if you use <code>$var = join',', @ids;</code> and execute with this $var, you'll get <code>... where id in ('1,2,3,4')</code> and the query will obviously fail. Can't trick DBI by setting the <c>{ TYPE => SQL_INTEGER }</c> attribute since it'll recognize it as a string and quote it anyway (and complain about the error).
<p>As an alternative, [dist://DBIx-Simple] has a "??" placeholder which is replaced with a list of as many question marks as values. Btw, I've only started looking at this module and haven't checked the speed in production.
<p>So, for example, your code fragment might look like:
<c>my @ids = (1,2,3,4);
my $query = 'select * from a_table where id in (??)';
my $result = $dbh->query($q, @ids);</c>
The <c>prepare</c> is taken care of internally and rows can be fetched in various ways.
667081
667081