in reply to getting the sql of a parameterised query

In the general case, it's irrelevant, for several reasons:

Since you can track the SQL you give to prepare and have access to the arguments you pass the execute function, I'd suggest just logging that in the event of an error. You could even replace the values yourself. Something like the naive:

$ST=$DB->prepare($SQL); if (! $ST->execute(@args)) { $SQL=~s/\?/$_/ for @args; print "STATEMENT: $SQL\nERROR: $DBI::errstr\n\n"; }

could be enough to do the trick. (Yes, it's buggy: for the same reasons that you don't just composite the SQL command and data values and execute it that way. But for debugging purposes, it should do just fine.)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: getting the sql of a parameterised query
by Anonymous Monk on Dec 07, 2010 at 13:08 UTC
    thanks - it is just for debugging to write the statements in a log. I know i have access to all of the information but i was hoping i could get the sql from the dbi rather than preparing it myself.