From: | Jeff Boes <jboes(at)nexcerpt(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: escape single quote in INSERT command |
Date: | 2002-11-22 18:38:17 |
Message-ID: | arltil$2l7q$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, 22 Nov 2002 08:00:01 -0500, Hunter wrote:
> I have a perl application for a registration form. I'd like to put
> escape characters in my insert command to accommodate for ' (i.e.
> O'Brien, O'Malley, etc). I've tired double quotes, single quotes, back
> tick, forward ticks, curly bracket, round brackets - no success.
Are you using the DBI interface? That's the most straightforward way to
accomplish this. Something like this:
use strict;
use DBI;
my $dbh = DBI->new(...see docs for details...);
$dbh->do(q|INSERT INTO mytable (col1) VALUES (?)|, undef,
q|O'Malley|) or die $DBI::errstr;
$dbh->commit;
By using the '?' placeholder format for statements, you can pass in any
data without having to worry about quoting.
--
Jeff Boes vox 616.226.9550 ext 24
Database Engineer fax 616.349.9076
Nexcerpt, Inc. http://www.nexcerpt.com
...Nexcerpt... Extend your Expertise
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Young | 2002-11-22 19:44:20 | join question |
Previous Message | Jeff Boes | 2002-11-22 18:34:57 | Re: calculating interval |