加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 当我使用DBI为非select语句准备/执行时,如何获取受影响

发布时间:2020-12-15 23:25:14 所属栏目:大数据 来源:网络整理
导读:根据 DBI文档,似乎我只能通过do方法获取受影响的行数. $rows_affected = $dbh-do("UPDATE your_table SET foo = foo + 1"); 如果使用prepare / execute,如何获得相同的结果? 解决方法 从有关 execute method in DBI的文档: For a non-“SELECT” statement
根据 DBI文档,似乎我只能通过do方法获取受影响的行数.

$rows_affected = $dbh->do("UPDATE your_table SET foo = foo + 1");

如果使用prepare / execute,如何获得相同的结果?

解决方法

从有关 execute method in DBI的文档:

For a non-“SELECT” statement,“execute” returns the number of rows affected,if known. If no rows were affected,then “execute” returns “0E0”,which Perl will treat as 0 but will regard as true. Note that it is not an error for no rows to be affected by a statement. If the number of rows affected is not known,then “execute” returns -1.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读