[ 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?
> I know it will be easy when I find out how:-)
> I also know there's bound to be more than one way to do it :-)
my $sql = q(select * from table where column = ?);
my $sth = $dbh->prepare($sql);
# this does the interpolation and the quoting and the escaping
$sth->execute($variable);
# and just my personal favourite
my $result = $sth->fetchall_arrayref({});
I suggest the DBI manual page, it's very good.
Steve
--
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