pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Carrigan <dave@rudedog.org>
To: Tod McQuillin <devin@spamcop.net>
Cc: Vincent Stoessel <vincent@xaymaca.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: escaping arrays in perl dbi
Date: 09 May 2002 08:28:43 -0700
Message-ID: <87lmattk5w.fsf@cbgb.rudedog.org> (raw)
In-Reply-To: <Pine.GSO.4.44.0205090932520.8544-100000@sysadmin>
References: <Pine.GSO.4.44.0205090932520.8544-100000@sysadmin>

Tod McQuillin <devin@spamcop.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@rudedog.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/                     | 



view thread (6+ messages)  latest in thread

Message-ID: <87lmattk5w.fsf@cbgb.rudedog.org>
Permalink:  ../87lmattk5w.fsf@cbgb.rudedog.org/
Also on:    postgresql.org/message-id/87lmattk5w.fsf@cbgb.rudedog.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dave@rudedog.org, devin@spamcop.net, vincent@xaymaca.com
  Subject: Re: escaping arrays in perl dbi
  In-Reply-To: <87lmattk5w.fsf@cbgb.rudedog.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox