dbSendStatement() method only submits and synchronously executes the
SQL data manipulation statement (e.g.,
DROP TABLE, ...) to the database engine. To query
the number of affected rows, call
dbGetRowsAffected() on the
returned result object. You must also call
that. For interactive use, you should almost always prefer
A DBIConnection object, as returned by
a character string containing SQL.
Other parameters passed on to methods.
dbSendStatement() comes with a default implementation that simply
dbSendQuery(), to support backends that only
implement the latter.
an S4 object that inherits from DBIResult.
The result set can be used with
determine the number of rows affected by the query.
Once you have finished using a result, make sure to clear it
An error is raised when issuing a statement over a closed
or invalid connection,
if the syntax of the statement is invalid,
or if the statement is not a non-
The following argument is not part of the
(to improve compatibility across backends)
but is part of the DBI specification:
It must be provided as named arguments. See the "Specification" sections for details on its usage.
No warnings occur under normal conditions.
When done, the DBIResult object must be cleared with a call to
Failure to clear the result set leads to a warning
when the connection is closed.
If the backend supports only one open result set per connection,
issuing a second query invalidates an already open result set
and raises a warning.
The newly opened result set is valid
and must be cleared with
param argument allows passing query parameters, see
dbBind() for details.
Other DBIConnection generics:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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 # Pass one set of values directly using the param argument: rs <- dbSendStatement( con, "INSERT INTO cars (speed, dist) VALUES (?, ?)", param = list(4L, 5L) ) dbClearResult(rs) # Pass multiple sets of values using dbBind(): rs <- dbSendStatement( con, "INSERT INTO cars (speed, dist) VALUES (?, ?)" ) dbBind(rs, list(5:6, 6:7)) dbBind(rs, list(7L, 8L)) dbClearResult(rs) dbReadTable(con, "cars") # there are now 10 rows dbDisconnect(con)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.