Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 imbibing at the Monastery: (5)
As of 2014-09-30 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (386 votes), past polls