Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Is there a way to display the statement generated by DBD on execute()

by moritz (Cardinal)
on May 05, 2013 at 06:09 UTC ( #1032104=note: print w/ replies, xml ) Need Help??


in reply to Is there a way to display the statement generated by DBD on execute()

$sth->execute (usually) doesn't create any SQL at all. Most DBD modules pass the string as-is to the database engine, which often directly support prepared statements.

That said, DBI supports tracing, which allows you to find out what happens between DBI/DBD and the database. See the section TRACING in the DBI docs.

Finally a possible way to create your SQL is this:

my @exclude_ids = (88, 99); my $sql = 'SELECT * FROM blog WHERE ID NOT IN (' . join(', ', ('?') x +@exclude_ids) . ')'; my $sth = $dbh->prepare($sql); $sth->execute(@exclude_ids);


Comment on Re: Is there a way to display the statement generated by DBD on execute()
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-06 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls