where the number of placeholders is unknown at compile time.SELECT * FROM my_table WHERE id_column IN (?, ?, ?, ?)
Note that the first three occurences of @values are in a scalar context.
my @sths; while (<>) { my @values = split ' ', $_; $sths[@values] ||= $dbh->prepare("SELECT * FROM my_table WHERE id_column IN (" . join(', ', ('?') x @values) . ')'); $sths[@values]->execute(@values); # ... }
|
|---|