Re: escaping arrays in perl dbi - Mailing list pgsql-sql

From Tod McQuillin
Subject Re: escaping arrays in perl dbi
Date
Msg-id Pine.GSO.4.44.0205090932520.8544-100000@sysadmin
Whole thread Raw
In response to escaping arrays in perl dbi  (Vincent Stoessel <vincent@xaymaca.com>)
Responses Re: escaping arrays in perl dbi
List pgsql-sql
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




pgsql-sql by date:

Previous
From: Vincent Stoessel
Date:
Subject: escaping arrays in perl dbi
Next
From: James Orr
Date:
Subject: Help with indexes