For many databases placeholders aren't just a textual substitution. It needs a real column name there in order to compile it to whatever internal representation the handle has. You really need to consult the specific DBD::Foo and database documentation to tell what's alowable as a placeholder and what's not. What you might could do is to prepare a handle for each column you plan on using:
my %sth; foreach( qw( guest name shoe_size ) ) { $sth{$_} = $dbh->prepare( qq{ SELECT distinct email from contacts where $_ = ? order by email }) or warn "Error preparing for $_: " . $dbh->errstr . "\n"; }
You could even build the handles dynamically on demand as they're needed.
$sth{$column} ||= $dbh->prepare( make_select( $column ) );
In reply to Re: Passing a value into a WHERE clause
by Fletch
in thread Passing a value into a WHERE clause
by peppiv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |