dbCommit {DBI}R Documentation

DBMS Transaction Management

Description

Commit/rollback SQL transactions

Usage

  dbCommit(conn, ...)
  dbRollback(conn, ...)

Arguments

conn a DBIConnection object, as produced by the function dbConnect.
... any database-specific arguments.

Details

Not all database engines implement transaction management, older versions of MySQL, for instance.

Value

a logical indicating whether the operation succeeded or not.

Side Effects

The current transaction on the connections con is committed or rolled back.

References

See the Database Interface definition document DBI.pdf in the base directory of this package or http://developer.r-project.org/db.

See Also

dbConnect dbSendQuery dbGetQuery fetch dbCommit dbGetInfo dbReadTable

Examples

## Not run: 
ora <- dbDriver("Oracle")
con <- dbConnect(ora)
rs <- dbSendQuery(con, 
      "delete * from PURGE as p where p.wavelength<0.03")
if(dbGetInfo(rs, what = "rowsAffected") > 250){
  warning("dubious deletion -- rolling back transaction")
  dbRollback(con)
}
## End(Not run)

[Package DBI version 0.2-4 Index]