dbSendStatement {DBI} | R Documentation |
The function dbSendStatement
only submits and synchronously executes the
SQL data manipulation statement (e.g., UPDATE
, DELETE
,
INSERT INTO
, DROP TABLE
, ...) to the database engine. To query
the number of affected rows, call dbGetRowsAffected
on the
returned result object. You must also call dbClearResult
after
that. For interactive use, you should almost always prefer
dbExecute
.
dbSendStatement(conn, statement, ...)
conn |
A |
statement |
a character vector of length 1 containing SQL. |
... |
Other parameters passed on to methods. |
dbSendStatement
comes with a default implementation that simply
forwards to dbSendQuery
, to support backends that only
implement the latter.
An object that inherits from DBIResult
.
Once you have finished using a result, make sure to disconnect it
with dbClearResult
.
For queries: dbSendQuery
and dbGetQuery
.
Other DBIConnection generics: DBIConnection-class
,
dbDataType
, dbDisconnect
,
dbExecute
, dbExistsTable
,
dbGetException
, dbGetInfo
,
dbGetQuery
, dbIsValid
,
dbListFields
, dbListResults
,
dbListTables
, dbReadTable
,
dbRemoveTable
, dbSendQuery
con <- dbConnect(RSQLite::SQLite(), ":memory:") dbWriteTable(con, "cars", head(cars, 3)) rs <- dbSendStatement(con, "INSERT INTO cars (speed, dist) VALUES (1, 1), (2, 2), (3, 3);") dbHasCompleted(rs) dbGetRowsAffected(rs) dbClearResult(rs) dbReadTable(con, "cars") # there are now 6 rows dbDisconnect(con)