Learn R Programming

ROracle (version 1.1-12)

dbSendQuery-methods: Execute a statement on a given database connection

Description

These methods are straight-forward implementations of the corresponding generic functions except for the execute method which is an ROracle specific DBI extension.

Usage

## S3 method for class 'OraConnection,character':
dbSendQuery(conn, statement, data = NULL,
          prefetch = FALSE, bulk_read = 1000L, bulk_write = 1000L, ...)
## S3 method for class 'OraConnection,character':
dbGetQuery(conn, statement, data = NULL,
          prefetch = FALSE, bulk_read = 1000L, bulk_write = 1000L, ...)
## S3 method for class 'OraResult':
dbClearResult(res, ...)
## S3 method for class 'OraConnection':
dbGetException(conn, ...)

execute(res, ...) ## S3 method for class 'OraResult': execute(res, data = NULL, ...)

Arguments

conn
An OraConnection object.
statement
A character vector of length 1 with the SQL statement.
res
An OraResult object.
data
A data.frame specifying bind data
prefetch
A logical value indicating TRUE or FALSE. When set to TRUE, ROracle will use OCI prefetch buffers to retrieve additional data from the server thus saving memory required in RODBI/ROOCI by allocating a single row buffer to fetch the data from
bulk_read
An integer value indicating the number of rows to fetch at a time. Default is 1000L. When the prefetch option is selected, memory is allocated for prefetch buffers and OCI will fetch those many rows at a time. When prefetch is not used (defaul
bulk_write
An integer value indicating the number of rows to write at a time. The default value is 1000L. When the bulk_write value is given in argument, memory is allocated for buffers and OCI will write that many rows at a time. When bulk_write argumen
...
Currently unused.

Value

  • dbSendQueryAn object OraResult whose class extends DBIResult. This object is used to fetch data from database, using the function fetch.

References

For the Oracle Database documentaion see http://www.oracle.com/technetwork/indexes/documentation/index.html.

Details

[object Object],[object Object],[object Object],[object Object],[object Object]

See Also

Oracle, dbDriver, dbConnect, fetch, dbCommit, dbGetInfo, dbReadTable.

Examples

Run this code
drv <- dbDriver("Oracle")
    con <- dbConnect(drv, "scott", "tiger")
    res <- dbSendQuery(con, "select * from emp where deptno = :1",
                       data = data.frame(deptno = 10))
    data <- fetch(res, n = -1)
    res2 <- dbSendQuery(con, "select * from emp where deptno = :1",
                        data1 = data.frame(deptno = 10), prefetch=TRUE,
                        bulk_read=2L)
    data1 <- fetch(res2, n = -1)
    res3 <- dbSendQuery(con, "select * from emp where deptno = :1",
                        data2 = data.frame(deptno = 10), bulk_read=10L)
    data2 <- fetch(res3, n = -1)
    res4 <- dbSendQuery(con, "select * from emp where deptno = :1",
                        data3 = data.frame(deptno = 10), bulk_write=10L)
    data3 <- fetch(res4, n = -1)
    res5 <- dbSendQuery(con, "select * from emp where ename = :1",
                        data4 = data.frame(ename = 'SMITH')) 
    data4 <- fetch(res5, n = -1)

Run the code above in your browser using DataLab