OraPreparedStatement-class {ROracle}R Documentation

Oracle Prepared Statement

Description

A class that encapsulates the information on an Oracle prepared statement

Objects from the Class

Use the method dbPrepareStatement to create an Oracle prepared statement and dbExecStatement to re-bind new data and execute the cached statement.

Slots

Id:
an opaque reference into the prepared statement.

Extends

Class "DBIPreparedStatement", directly. Class "OraResult", directly. Class "DBIObject", by class "DBIPreparedStatement". Class "DBIResult", by class "OraResult". Class "OraObject", by class "OraResult". Class "dbObjectId", by class "OraResult".

Methods

dbExecStatement
signature(ps = "OraPreparedStatement", data = "data.frame"): executes a prepared statement re-binding new data to it.
dbGetInfo
signature(dbObj = "OraPreparedStatement"): returns a list of metadata associated with the prepared statement.
summary
signature(object = "OraPreparedStatement"): writes a brief summary of the status of the prepared statement.

Background

Oracle's prepared statements (like other RDBMS') are SQL statements that are parsed and cached to increase performance when the SQL code is to be executed repeatedly but with different data; for instance when inserting the rows of a data.frame into a table the SQL for each row is exactly the same, only the row data changes.

The function dbPrepareStatement creates objects that extend the base class DBIPreparedStatement. These objects are simple references into C structures that store the various aspects (the text of the SQL statement, sets of buffers for transferring data back and forth, etc).

The function dbExecStatement takes a prepared statement object and a data.frame and binds one or more of its columns to the RDBMS table or object according to the specification in the prepared statement.

Note

As of the DBI version 0.1-5 prepared statements are not part of the R/S Database Interface definition (DBI).

References

See the Database Interface definition document DBI.pdf in the base directory of this package or http://stat.bell-labs.com/RS-DBI.

See Also

DBI classes: OraObject-class OraDriver-class OraConnection-class OraResult-class OraPreparedStatement-class

Examples

## Not run: 
  ora <- dbDriver("Oracle")
  con <- dbconnect(ora, "user/password")
  ps <- dbPrepareStatement(con, 
           "INSERT into QUAKES (lat, long_1) VALUES (:1, :2)",
           bind = c("numeric", "numeric"))
  dbExecStatement(ps, quakes)
  dbCommit(con)
## End(Not run)

[Package ROracle version 0.5-7 Index]