dbSendStatement

0th

Percentile

Execute a data manipulation statement on a given database connection

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.

Usage
dbSendStatement(conn, statement, ...)
Arguments
conn
A DBIConnection object, as produced by dbConnect.
statement
a character vector of length 1 containing SQL.
...
Other parameters passed on to methods.
Details

dbSendStatement comes with a default implementation that simply forwards to dbSendQuery, to support backends that only implement the latter.

Value

An object that inherits from DBIResult. Once you have finished using a result, make sure to disconnect it with dbClearResult.

See Also

For queries: dbSendQuery and dbGetQuery.

Other DBIConnection generics: DBIConnection-class, dbDataType, dbDisconnect, dbExecute, dbExistsTable, dbGetException, dbGetInfo, dbGetQuery, dbIsValid, dbListFields, dbListResults, dbListTables, dbReadTable, dbRemoveTable, dbSendQuery

Aliases
  • dbSendStatement
Examples
library(DBI) 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)
Documentation reproduced from package DBI, version 0.5-1, License: LGPL (>= 2)

Community examples

Looks like there are no examples yet.