[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
J Wonnacott wrote: > I need to pass a variable to the WHERE clause, however when the variable hits the > SQL server it should appear in single quotes i.e. WHERE person_id = '<interpolated > $variable>'. > How do I send '$variable' but still get it interpolated? It's still interpolated. The single quotes are just characters when enclosed in outer double-quotes. my $dbh = DBI->connect ($dsn, $dbusername, $dbpassword) my $sth = $dbh->prepare("SELECT * FROM table WHERE person_id = '$variable'"); $sth->execute(); my @row = $sth->fetchrow_array; $sth->finish(); $dbh->disconnect(); If building complicated queries, I find it easier to do a string first, but that's just me. my $sql = "SELECT * FROM table WHERE person_id = '$variable'"; my $sth = $dbh->prepare($sql); -- Simon Avery -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html