How can I print the SQL query executed after Perl's DBI fills in the placeholders?

前端 未结 8 794
梦毁少年i
梦毁少年i 2021-02-05 09:36

I\'m using Perl\'s DBI module. I prepare a statement using placeholders, then execute the query.

Is it possible to print out the final query that was executed without ma

8条回答
  •  萌比男神i
    2021-02-05 10:01

    For the majority of queries, the simplest debugging is to use the following...

    • If you prepare and execute a single statement using do method, use:

      use feature 'say';
      say $dbh->{Statement};
      
    • If you use prepare and execute methods separately, use:

      use feature 'say';
      use Data::Dumper;
      say $sth->{Statement};
      say Dumper($sth->{ParamValues});
      

提交回复
热议问题