Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

(dkubb) Re: (3) A more elegant solution?

by dkubb (Deacon)
on Jun 05, 2001 at 09:53 UTC ( #85707=note: print w/replies, xml ) Need Help??

in reply to Re: Re: A more elegant solution?
in thread A more elegant solution?

IIRC, the DBI spec doesn't support using placeholders for the column names, only values. Programming the Perl DBI, p 221 says the following:

With most drivers, placeholders can't be used for any element of a statement that would prevent the database server from validating the statement and creating a query execution plan for it. For example:

"SELECT name, age FROM ?" #wrong (will probably fail) "SELECT name, ? FROM people" #wrong (but may not 'fail')

While this may not fail with some databases like MySQL, it *may* fail on databases like Oracle that natively support placeholders. (can anyone confirm this?)

Replies are listed 'Best First'.
Re: (dkubb) Re: (3) A more elegant solution?
by da (Friar) on Jun 06, 2001 at 21:43 UTC
    Here's what happens under oracle:
    # fails under oracle my $sth = $dbh->prepare("select name, age from ?") # does not fail under oracle, but gives wrong results. my $sth = $dbh->prepare("select name, ? from table") # outputs n copies of the string "age", for n rows in table. $sth->execute("age")


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://85707]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2017-05-24 23:01 GMT
Find Nodes?
    Voting Booth?