gpt4 book ai didi

perl-dbi - 检索已执行的语句

转载 作者:行者123 更新时间:2023-12-04 21:14:32 29 4
gpt4 key购买 nike

所以我有这个非常简化的片段:

@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?>

问题:如何在数据绑定(bind)发生后检索语句 AS EXECUTED ?如果出现问题,我想要一种方法来捕获执行的实际语句,包括绑定(bind)值。

最佳答案

你问:

how can I retrieve the statement AS EXECUTED ie after data-binding as occured ?



一般你不能。大多数非玩具 RDBMS 将执行绑定(bind)服务器端,而不是客户端,并且大多数非玩具 perl DBD 驱动程序将利用这一点。检查数据库服务器的日志。

但是, DBI's tracing facility可能会给你足够的继续。祝你好运。

更新

评论中的 user4035 链接到相关的 perlmonks thread它提供了所需绑定(bind)变量插值的模拟。

关于perl-dbi - 检索已执行的语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17796054/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com