Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

    ___
    -DA

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://85707]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-07-30 21:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls