Learn R Programming

DBI (version 1.2.2)

dbGetStatement: Get the statement associated with a result set

Description

Returns the statement that was passed to dbSendQuery() or dbSendStatement().

DBI:::methods_as_rd("dbGetStatement")

Usage

dbGetStatement(res, ...)

Value

dbGetStatement() returns a string, the query used in either dbSendQuery() or dbSendStatement().

Arguments

res

An object inheriting from DBIResult.

...

Other arguments passed on to methods.

Failure modes

Attempting to query the statement for a result set cleared with dbClearResult() gives an error.

See Also

Other DBIResult generics: DBIResult-class, dbBind(), dbClearResult(), dbColumnInfo(), dbFetch(), dbGetInfo(), dbGetRowCount(), dbGetRowsAffected(), dbHasCompleted(), dbIsReadOnly(), dbIsValid(), dbQuoteLiteral(), dbQuoteString()

Examples

Run this code
if (FALSE) { # requireNamespace("RSQLite", quietly = TRUE)
con <- dbConnect(RSQLite::SQLite(), ":memory:")

dbWriteTable(con, "mtcars", mtcars)
rs <- dbSendQuery(con, "SELECT * FROM mtcars")
dbGetStatement(rs)

dbClearResult(rs)
dbDisconnect(con)
}

Run the code above in your browser using DataLab