Learn R Programming

ROracle (version 1.3-1)

dbDriver-methods: Oracle Implementation of the Database Interface (DBI) Classes and Drivers

Description

Oracle driver initialization and closing.

Usage

# S4 method for OraDriver
dbUnloadDriver(drv, ...)
# S4 method for ExtDriver
dbUnloadDriver(drv, ...)

Arguments

drv

An object that inherits from OraDriver or ExtDriver as created by dbDriver.

...

Any other arguments to pass to the driver drvName.

Value

dbDriver

An object OraDriver or ExtDriver whose class extends DBIDriver. This object is used to create connections, using the function dbConnect, to one or more Oracle Database engines.

dbUnloadDriver

Free all resources occupied by the driver object.

Side Effects

dbDriver

The R client part of the database communication is initialized, but note that connecting to the database engine needs to be done through calls to dbConnect.

dbUnloadDriver

Remove the communication link between the R client and the database.

Details

dbDriver

This object is a singleton, that is, subsequent invocations of dbDriver return the same initialized object.

This implementation allows you to connect to multiple host servers and run multiple connections on each server simultaneously.

When interruptible is set to TRUE, it allows for interrupting long-running queries on the server by executing the query in a thread. Main thread checks for Ctrl-C and issues OCIBreak/OCIReset to cancel the operation on the server. By default, interruptible is FALSE.

When unicode_as_utf8 is set to FALSE, NCHAR, NVARCHAR and NCLOB data is fetched using the character set specified by the NLS_LANG setting. By default, unicode_as_utf8 is set to TRUE.

When ora.attributes is set to TRUE, the result set from dbGetQuery and fetch contains DBMS-specific attributes like ora.encoding, ora.type, and ora.maxlength for the corresponding column.

dbUnloadDriver

This implementation removes communication links between the R client and the database. It frees all connections and all result sets associated with those connection objects.

References

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

See Also

Oracle, dbConnect, dbSendQuery, dbGetQuery, fetch, dbCommit, dbGetInfo, dbListTables, dbReadTable.

Examples

Run this code
# NOT RUN {
  
# }
# NOT RUN {
    # first load the library
    library("ROracle")

    # create an Oracle instance
    drv <- dbDriver("Oracle")

    con <- dbConnect(drv, "scott", "tiger")
    dbListTables(con)

    # fetch all results from the emp table
    res <- dbGetQuery(con, "select * from emp")

    # dbSendQuery can be used to fetch data in chunks 
    # as well as all of data at once
    res <- dbSendQuery(con, "select * from emp")

    # fetch all results
    fetch(res)

    # or a chunk at a time
    fetch(res, n = 5)

    # describing the schema for the emp table using dbGetInfo
    dbGetInfo(res, what = 'fields')

    # clear the result
    dbClearResult(res)

    # disconnect from the database
    dbDisconnect(con)

    # free the driver object
    dbUnloadDriver(drv)
  
# }

Run the code above in your browser using DataLab