dbGetRowsAffected: The number of rows affected

Description Usage Arguments Value See Also Examples

Description

This method returns the number of rows that were added, deleted, or updated by a data manipulation statement.

\Sexpr[results=rd,stage=render]{DBI:::methods_as_rd("dbGetRowsAffected")}

Usage

1

Arguments

res

An object inheriting from DBIResult.

...

Other arguments passed on to methods.

Value

dbGetRowsAffected() returns a scalar number (integer or numeric), the number of rows affected by a data manipulation statement issued with dbSendStatement(). The value is available directly after the call and does not change after calling dbFetch(). For queries issued with dbSendQuery(), zero is returned before and after the call to dbFetch(). Attempting to get the rows affected for a result set cleared with dbClearResult() gives an error.

See Also

Other DBIResult generics: DBIResult-class, dbBind, dbClearResult, dbColumnInfo, dbFetch, dbGetInfo, dbGetRowCount, dbGetStatement, dbHasCompleted, dbIsReadOnly, dbIsValid, dbQuoteIdentifier, dbQuoteLiteral, dbQuoteString, dbUnquoteIdentifier

Examples

1
2
3
4
5
6
7
8
9
con <- dbConnect(RSQLite::SQLite(), ":memory:")

dbWriteTable(con, "mtcars", mtcars)
rs <- dbSendStatement(con, "DELETE FROM mtcars")
dbGetRowsAffected(rs)
nrow(mtcars)

dbClearResult(rs)
dbDisconnect(con)

DBI documentation built on May 2, 2018, 5:04 p.m.