Perl-dbi - getting instructions as executed

So, I have this extremely simplified snippet:

@cmd_arry = ("Bob Newhart", "54"); $sqlCmd = "UPDATE foobar SET name = ?, age = ?"; $sth = $dbh->prepare( $sqlCmd); $resultCnt = $sth->execute( @cmd_arry); if( my $errMsg = $dbh->errstr) { $what_actually_executed = <what?> 

Question: how can I get the AS EXECUTED statement, i.e. after data binding? I need a way to capture an executable statement, related related values, if something goes wrong.

+4
source share
1 answer

You're asking:

How can I get the AS EXECUTED statement, that is, after data binding, how did this happen?

Generally, you cannot. Most non-toy DBMSs will bind to the server side, not the client side, and most non-toy DBDs will use this. Check the database server logs.

However, the DBI trace facility can give you enough room to continue. Good luck.

UPDATE

user4035 links in the comments to the corresponding perlmonks thread , which offers a simulation of the required interpolation of the binding variables.

+6
source

Source: https://habr.com/ru/post/1492783/


All Articles