获取受影响的总行数,当使用 SQLExecDirect 更新时

Get total rows count those are affected, WHEN update with SQLExecDirect

如果我使用SQLExecDirect执行查询:

UPDATE mytable set mycol = 2 where mycol = 1;

我如何知道有多少行已更新?

参考Here

函数原型:

SQLRETURN SQLRowCount(
  SQLHSTMT hstmt,           /* 32-bit input -- statement handle */
  SQLINTEGER *RowCount      /* 32-bit output */
  );

示例:-

#include "sqlcli.h"
SQLINTEGER row_count;
...
if (SQLExecDirect(hstmt,"UPDATE QUERY HERE;",SQL_NTS)>=0) {
  if (SQLRowCount(hstmt,&row_count)>=0) {
    /* The value of row_count is 1. */ } }