DBI::execute(): how to evade quoting identifier names
- From: a.l.w.kuijper@xxxxxx (Bram Kuijper)
- Date: Tue, 02 Jan 2007 18:07:56 +0100
Hi all,
thanks for the quick solution to my previous __FUNCTION__ question. I have another problem:
I try to execute the following SQL query in PostGreSQL 8.1. However, it gives errors since DBI::execute() automatically quotes when it inserts its arguments into the SQL query. Is there any way to change the quoting behavior of DBI::execute():
# make SQL statement
my $qry = "ALTER TABLE mytable ALTER COLUMN ? TYPE double precision;
# prepare SQL-statement
my $qry_sth = $dbh->prepare($qry);
# execute SQL statement with user-defined column name added
$qry_sth->execute($col_name);
which results in the following query being executed:
ALTER TABLE mytable ALTER COLUMN 'column_name' TYPE double precision
The inserted variable, which is an identifier, will receive single quotes by DBI::execute(). PostGreSQL gives an error, since it only accepts unquoted identifiers. How can I change DBI::prepare() or DBI::execute default behavior, so that added values go unquoted?
I have the idea that this should be done by adding some statement handling attribute to the $qry_sth object, but the DBI documentation is not very explicit about it.
thanks for any help,
Bram
.
- Follow-Ups:
- Re: DBI::execute(): how to evade quoting identifier names
- From: "D. Bolliger"
- Re: DBI::execute(): how to evade quoting identifier names
- From: Paul Lalli
- Re: DBI::execute(): how to evade quoting identifier names
- Prev by Date: Re: php's __FUNCTION__ equivalent in Perl
- Next by Date: Re: Unzip to newly created directory...
- Previous by thread: php's __FUNCTION__ equivalent in Perl
- Next by thread: Re: DBI::execute(): how to evade quoting identifier names
- Index(es):
Relevant Pages
|