in reply to DBI and variable numbers of bind parameters
Another way is to use something like SQL::Abstract:my $sql = "SELECT foo FROM Bar WHERE 1=1"; my @bind; $sql .= " AND baz in ( " . join(',', map {'?'} @ins) . ") "; push @bind, @ins; $dbh->selectall_arrayref($sql, {}, @bind);
use SQL::Abstract; my $SA = SQL::Abstract->new; my ($sql, @bind) = $SA->select('Bar', ['foo'], {baz => \@ins}); $dbh->selectall_arrayref($sql, {}, @bind);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI and variable numbers of bind parameters
by diotalevi (Canon) on Oct 18, 2005 at 15:10 UTC |