in reply to Seeing the query used by a prepared statement

See TRACING section in DBI documentation

  • Comment on Re: Seeing the query used by a prepared statement

Replies are listed 'Best First'.
Re^2: Seeing the query used by a prepared statement
by aquarium (Curate) on Nov 01, 2010 at 02:21 UTC
    and likewise check any tracelogs on the database server, which should show the exact statement received before execution. you may need to turn on such server side detail tracing in the first place, and that will vary depending on you DB engine.
    the hardest line to type correctly is: stty erase ^H

      the above recommendations are probably better (i'm not looking at the dbi page right now, might say the same thing), but here's what i do:

      my $select = qq/SELECT * /; my $from = qq/FROM db/; my $query = $select . $from; # print "SQL: $query\n"; my $sth = $dbh->prepare( $query ); $sth->execute;

      note the print statement. also, it's not secure in any way - just for testing. also, iirc the perl taint doesn't effect dbi data - separate taint.