in reply to DBI - Get prepared/populated sql statement

According to DBI, you can recover the statement passed to your prepare statement either through the statement handle or the database handle, by invoking the statement attribute. In your code, this could be done with:

my $sth = $dbh->prepare(<<EOQ); select tbl.column1, tbl2.column2 from tbl1, tbl2 where condition = ? EOQ print $sth->{statement};

Replies are listed 'Best First'.
Re^2: DBI - Get prepared/populated sql statement
by mhearse (Chaplain) on Mar 10, 2009 at 16:36 UTC
    That works great. Thanks!

    Oops. I spoke too soon. $dbh->{Statement} gives only the raw query. For debugging purposes, I'd like to have the query which has been populated with arguments from $dbh->execute(). Oh well....