DBI (version 0.4-1)

dbGetQuery: Send query, retrieve results and then clear result set.

Description

dbGetQuery comes with a default implementation that calls dbSendQuery, then dbFetch, ensuring that the result is always free-d by dbClearResult.

Usage

dbGetQuery(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.

Implementation notes

Subclasses should override this method only if they provide some sort of performance optimisation.

See Also

Other connection methods: dbDisconnect, dbExistsTable, dbGetException, dbListFields, dbListResults, dbListTables, dbReadTable, dbRemoveTable, dbSendQuery

Examples

Run this code
if (require("RSQLite")) {
con <- dbConnect(RSQLite::SQLite(), ":memory:")

dbWriteTable(con, "mtcars", mtcars)
dbGetQuery(con, "SELECT * FROM mtcars")

dbBegin(con)
dbGetQuery(con, "DELETE FROM mtcars WHERE cyl == 4")
dbRollback(con)

dbDisconnect(con)
}

Run the code above in your browser using DataCamp Workspace