pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tod McQuillin <devin@spamcop.net>
To: Vincent Stoessel <vincent@xaymaca.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: escaping arrays in perl dbi
Date: Thu, 9 May 2002 09:36:15 -0500 (CDT)
Message-ID: <Pine.GSO.4.44.0205090932520.8544-100000@sysadmin> (raw)
In-Reply-To: <3CDA83BB.5000006@xaymaca.com>

On Thu, 9 May 2002, Vincent Stoessel wrote:

> I am trying to figure out how I need to change the string below in
> order to do an insert into my table using perl dbi. perl seems to choke
> on the curly brackets. Any help would be appriciated.
>
> $dbh->do("update basket set f_order ='{"apple",0}' where cap ='I'");

You are using double quotes as your string delimiter, and also double
quotes inside it.

Probably this would work:

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

or this:

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

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.
-- 
Tod McQuillin





view thread (6+ messages)  latest in thread

Message-ID: <Pine.GSO.4.44.0205090932520.8544-100000@sysadmin>
Permalink:  ../Pine.GSO.4.44.0205090932520.8544-100000@sysadmin/
Also on:    postgresql.org/message-id/Pine.GSO.4.44.0205090932520.8544-100000@sysadmin

 · 

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: devin@spamcop.net, vincent@xaymaca.com
  Subject: Re: escaping arrays in perl dbi
  In-Reply-To: <Pine.GSO.4.44.0205090932520.8544-100000@sysadmin>

* 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