R Getting the number of rows which have been updated

血红的双手。 提交于 2020-01-16 01:15:52

问题


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)...


回答1:


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.



来源:https://stackoverflow.com/questions/25762371/r-getting-the-number-of-rows-which-have-been-updated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!