Re: escape single quote in INSERT command
От | Jeff Boes |
---|---|
Тема | Re: escape single quote in INSERT command |
Дата | |
Msg-id | arltil$2l7q$1@news.hub.org обсуждение исходный текст |
Список | 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
В списке pgsql-sql по дате отправления: