http://qs321.pair.com?node_id=672767

dgaramond2 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I have lots of complex SQL in my script in the form:

$dbh->do("INSERT ... etc ... (FOO(?), ?, ?, ?, ?, ...)", {}, $var1, ...);

(yeah I know, I should use CDBI or Rose::DB or whatever. But this is actually some low-level data importing stuffs which require SQL tweaking.)

Sometimes when things do not go right, $dbh->do() failed with error from MySQL along the line of "syntax error near ) line 45". Since the SQL is pretty long/complex, is there a way to make DBI print the substituted/final SQL sent to the DB so I can better see which part is causing the syntax error?