DBI (version 0.1-10)

dbCommit-methods: 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.

Value

  • a logical indicating whether the operation succeeded or not.

Side Effects

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

Details

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

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

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

Run the code above in your browser using DataCamp Workspace