Learn R Programming

ROracle (version 1.1-12)

Oracle: 현재 R세션에서 Oracle 클라이언트 인스턴스화

Description

이 함수는 현재 R세션에서 Oracle 클라이언트를 생성하고 초기화합니다. 하나 이상의 Oracle 서버에 접속할 수 있는 객체를 반환합니다.

Usage

Oracle(interruptible = FALSE)
  Extproc(extproc.ctx = NULL)

Arguments

interruptible
사용자가 장기 실행 질의를 중단할 수 있는지 여부를 나타내는 논���입니다.
extproc.ctx
extproc 컨텍스트를 래핑하는 외부 포인터입니다.

Value

  • 해당 클래스가 OraDriver을(를) 확장하는 Oracle에 대한 ExtDriver 클래스 또는 Extproc에 대한 DBIDriver 클래스의 객체입니다. 이 객체는 dbConnect 함수를 사용하여 한 개 또는 여러 개의 Oracle Database 엔진에 대한 접속을 생성하는 데 사용됩니다.

Side Effects

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

Oracle user authentication

In order to establish a connection to an Oracle server users need to provide a user name, a password, and possibly 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 follows the '@' sign.

Connections to an Oracle TimesTen IMDB instance are established using the OCI tnsnames or easy connect naming methods. For additional information on TimesTen connections for OCI see chapter 3 (TimesTen Support for Oracle Call Interface) of the Oracle TimesTen In-Memory C Developer's Guide.

Transactions

The current implementation directly supports transaction commits and rollbacks on a connection-wide basis through calls to dbCommit and dbRollback. Save points are not yet directly implemented, but you may be able to define them and rollback to them through calls to dynamic SQL with dbGetQuery.

Notice that Oracle (and ANSI/ISO compliant DBMS) transactions are implicitly started when data definition SQL are executed (create table, etc.), which helper functions like dbWriteTable may execute behind the scenes. You may want or need to commit or roll back your work before issuing any of these helper functions.

References

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

Details

이 객체는 단일체입니다. 즉, 이후에 호출 시 똑같이 초기화된 객체를 반환합니다. 이 구현을 통해 여러 호스트 서버에 접속하고 각 서버에서 여러 접속을 동시에 실행할 수 있습니다. interruptible이 TRUE로 설정된 경우 서버에서 장기 실행 중인 질의를 스레드에서 실행하여 중단할 수 있습니다. 주 스레드는 Ctrl-C를 검사하고 OCIBreak/OCIReset을 발행하여 서버의 작업을 취소합니다. 기본적으로 interruptible은 FALSE입니다.

See Also

On database managers:

dbDriver dbUnloadDriver dbListConnections

On connections:

dbConnect dbDisconnect dbSendQuery dbGetQuery dbGetException dbListResults

Convenience methods: dbListTables dbReadTable dbWriteTable dbExistsTable dbRemoveTable dbListFields

On transaction management:

dbCommit dbRollback

On queries and result objects:

fetch dbClearResult dbColumnInfo dbGetStatement dbHasCompleted dbGetRowsAffected dbGetRowCount

On meta-data:

show summary dbGetInfo

Examples

Run this code
## create a Oracle instance and create one connection.
    ora <- Oracle()         ## or dbDriver("Oracle")
    con <- dbConnect(ora, username = "scott", password = "tiger", 
                     dbname = "inst1")

    ## if you are connecting to a local database
    con <- dbConnect(ora, username = "scott", password = "tiger")

    ## execute a statement and fetch its output in chunks of no more
    ## than 5000 rows at a time
    rs   <- dbSendQuery(con, "select * from emp where deptno = 10")
    while (!dbHasCompleted(rs)) {
      df <- fetch(rs, n = 5000)
      ## process df
    }
    dbClearResult(rs)       ## done with this query

    ## execute and fetch a statement with bind data
    df <- dbGetQuery(con, "select * from emp where deptno = :1",
                     data = data.frame(depno = 10))

    ## create a copy of emp table
    dbGetQuery(con, "create table foo as select * from emp")

    ## execute and bind an INSERT statement
    my.data = data.frame(empno = c(8001, 8002), ename = c('MUKHIN', 'ABOYOUN'))
    more.data = data.frame(empno = c(8003), ename = c('JAMES'))
    rs <- dbSendQuery(con, "insert into foo (empno, ename) values (:1, :2)",
                      data = my.data)

    ## execute with more data
    execute(rs, data = more.data)
    dbClearResult(rs)       ## done with this query

    ## ok, everything looks fine
    dbCommit(con)           

    ## a concise description of the driver 
    summary(ora)

    ## done with this connection
    dbDisconnect(con)

Run the code above in your browser using DataLab