Re: escaping arrays in perl dbi

From: Dave Carrigan <dave(at)rudedog(dot)org>
To: Tod McQuillin <devin(at)spamcop(dot)net>
Cc: Vincent Stoessel <vincent(at)xaymaca(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: escaping arrays in perl dbi
Date: 2002-05-09 15:28:43
Message-ID: 87lmattk5w.fsf@cbgb.rudedog.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tod McQuillin <devin(at)spamcop(dot)net> writes:

> But try using DBI parameters like this:
>
> $dbh->prepare("update basket set f_order = ? where cap = ?");
> $dbh->execute('{"apple",0}', 'I');
>
> DBI should take care of all the quoting and escaping for you.

This is the best way to do it, but you can shorten it with:

$dbh->do("update basket set f_order = ? where cap = ?",
undef, '{"apple",0}', 'I');

If you don't want to use the parameterized mechanism, Perl's qq operator
is your friend:

$dbh->do(qq(update basket set f_order = {"apple",0} where cap = 'I'));

--
Dave Carrigan (dave(at)rudedog(dot)org) | Yow! Why am I in this ROOM in
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | DOWNTOWN PHILADELPHIA?
Seattle, WA, USA |
http://www.rudedog.org/ |

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gabriel Dovalo Carril 2002-05-09 18:34:57 Re: Can this query be faster?
Previous Message Andrew Perrin 2002-05-09 14:44:50 Re: escaping arrays in perl dbi