## create a Oracle instance and create one connection.
ora <- Oracle() ## or dbDriver("Oracle")
con <- dbConnect(ora, user = "opto", password="pure-light", db="oras")
## you can also use Oracle's user/password@dbname convention
con2 <- dbConnect(ora, user = "opto/pure-light@oras")
## or if you have defined the ORACLE_SID shell variable
con3 <- dbConnect(ora, user = "opto", password = "pure-light")
## clone an existing connection
w <- dbConnect(con)
## execute a statement and fetch its output in chunks of no more
## than 5000 rows at a time
rs <- dbSendQuery(con, "select * from HTTP_ACCESS where IP_ADDRESS='127.0.0.1'")
while(!dbHasCompleted(rs)){
df <- fetch(rs, n = 5000)
process(df)
}
## a concise description of the driver
summary(ora)
<OraDriver:(24694)>
Driver name: Oracle (ProC/C++)
Max connections: 10
Conn. processed: 9
Default records per fetch: 500
Open connections: 2
## a full description of the ora connection
summary(con, verbose = T)
<OraConnection:(25272,0)>
User: opto
Dbname: oras
Oracle Server version:
Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
PL/SQL Release 8.0.4.0.0 - Production
CORE Version 4.0.4.0.0 - Production
TNS for Solaris: Version 8.0.4.0.0 - Production
NLSRTL Version 3.3.1.0.0 - Production
dbHasCompleted(rs)
[1] TRUE
dbClearResult(rs) ## done with this query
[1] TRUE
dbDisconnect(con) ## done with this connection
[1] TRUE
Run the code above in your browser using DataLab