Learn R Programming

ROracle (version 1.1-8)

dbConnect-methods: Create a connection object to an Oracle DBMS

Description

These methods are straight-forward implementations of the corresponding generic functions.

Usage

## S3 method for class 'OraDriver':
dbConnect(drv, username = "", password = "", dbname = "", prefetch = FALSE,
          bulk_read = 1000L, stmt_cache = 0L, ...)
## S3 method for class 'ExtDriver':
dbConnect(drv, prefetch = FALSE, bulk_read = 1000L, stmt_cache = 0L, ...)
## S3 method for class 'OraConnection':
dbDisconnect(conn, ...)

Arguments

drv
an object of class OraDriver or ExtDriver.
conn
an OraConnection object as produced by dbConnect.
username
a character string specifying a user name.
password
a character string specifying a password.
dbname
a character string specifying a connect identifier (for more informations refer to chapter 8 (Configuring Naming Methods) of Oracle Database Net Services Administrator's Guide). This is the same as part of the SQL*Plus connect string that foll
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(default
stmt_cache
an integer value indicating the number of statements to cache. It means that cursors are ready to be used without the need to parse the statements again. Default is 0L. Statement cache leads to prefetch.
...
currently unused.

Value

  • dbConnectAn object OraConnection whose class extends DBIConnection. This object is used to execute SQL query on database.
  • dbDisconnect

References

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

Details

[object Object],[object Object]

See Also

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

Examples

Run this code
## create an Oracle instance and create one connection.
    drv <- dbDriver("Oracle")

    ## use username/password authentication
    con <- dbConnect(drv, username = "scott", password = "tiger")

    ## run an SQL statement by creating first a resultSet object
    rs <- dbSendQuery(con, "select * from emp where deptno = 10")

    ## we now fetch records from the resultSet into a data.frame
    data <- fetch(rs)       ## extract all rows
    dim(data)
  ## create an Oracle instance and create one connection.
    drv <- dbDriver("Oracle")

    ## use Oracle wallet authentication
    con <- dbConnect(drv, username ="", password="", 
    dbname = "<wallet_connect_string>")

    ## run an SQL statement by creating first a resultSet object
    rs <- dbSendQuery(con, "select * from emp where deptno = 10")

    ## we now fetch records from the resultSet into a data.frame
    data <- fetch(rs)       ## extract all rows
    dim(data)
  ## create an Oracle instance and create one connection.
    drv <- dbDriver("Oracle")

    ## connect to a TimesTen IMDB instance using the easy connect 
    ## naming method where SampleDb is a direct driver TimesTen DSN
    con <- dbConnect(drv, username ="scott", password="tiger", 
                     dbname = "localhost/SampleDb:timesten_direct")

    ## run an SQL statement by creating first a resultSet object
    rs <- dbSendQuery(con, "select * from dual")

    ## we now fetch records from the resultSet into a data.frame
    data <- fetch(rs)       ## extract all rows
    dim(data)
  ## connect to a extproc (this assumes that the driver has already
    ## been initialized in the embeeded code by passing an external
    ## pointer representing extproc context)
    con <- dbConnect(Extproc())

    ## run an SQL statement by creating first a resultSet object
    rs <- dbSendQuery(con, "select * from dual")

    ## we now fetch records from the resultSet into a data.frame
    data <- fetch(rs)       ## extract all rows
    dim(data)

Run the code above in your browser using DataLab