Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

(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?)

Comment on (dkubb) Re: (3) A more elegant solution?
Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-03-29 04:26 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (630 votes), past polls