R Getting the number of rows which have been updat

2019-08-05 06:22发布

How can we get the number of rows affected by the executed UPDATE query?

r <- sqlQuery(channel, 'UPDATE foo SET bar = 1')

What I get (from a connection to a MS SQL Server DB) is just a character(0)...

标签: sql r odbc rodbc
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-05 07:07

From the Microsoft Data Access SDK ODBC Help guide:

SQLRowCount returns the number of rows affected by an UPDATE, INSERT, or DELETE statement; an SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or SQL_DELETE_BY_BOOKMARK operation in SQLBulkOperations; or an SQL_UPDATE or SQL_DELETE operation in SQLSetPos.

I expect that there is a way to invoke this ODBC function via the api you are using.

查看更多
登录 后发表回答