my @ids = ( 1, 2 );
my $value_lookup_sth = $dbh->prepare("
SELECT value
WHERE id IN (" . join(',', ('?') x @ids ) . ")
");
$value_lookup_sth->execute(@ids)
or debug($DBI::errstr);
####
sub plist { '(' . join( ',', ('?') x $_[0] ) . ')' }
my @ids = ( 1, 2 );
my $value_lookup_sth = $dbh->prepare("
SELECT value
WHERE id IN ".plist(0+@ids)."
");
$value_lookup_sth->execute(@ids)
or debug($DBI::errstr);
####
{
package My::plist;
use Tie::Array;
our @ISA = 'Tie::Array';
sub TIEARRAY { bless [], shift }
sub FETCH { '(' . join( ',', ('?') x $_[1] ) . ')' }
}
tie my @plist, 'My::plist';
my @ids = ( 1, 2 );
my $value_lookup_sth = $dbh->prepare("
SELECT value
WHERE id IN $plist[@ids]
");
$value_lookup_sth->execute(@ids)
or debug($DBI::errstr);