Learn R Programming

ROracle (version 0.5-12)

OraPreparedStatement-class: Oracle Prepared Statement

Description

A class that encapsulates the information on an Oracle prepared statement

Arguments

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.

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".

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.

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

Run this code
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)

Run the code above in your browser using DataLab