DBI (version 0.5-1)

transactions: Begin/commit/rollback SQL transactions

Description

Not all database engines implement transaction management, in which case these methods should not be implemented for the specific DBIConnection subclass.

Usage

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

Arguments

conn
A DBIConnection object, as produced by dbConnect.
...
Other parameters passed on to methods.

Value

a logical indicating whether the operation succeeded or not.

Side Effects

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

See Also

Self-contained transactions: dbWithTransaction

Examples

Run this code
## Not run: 
# ora <- dbDriver("Oracle")
# con <- dbConnect(ora)
# 
# rs <- dbSendQuery(con,
#       "delete * from PURGE as p where p.wavelength<0.03")
# if (dbGetRowsAffected(rs) > 250) {
#   warning("dubious deletion -- rolling back transaction")
#   dbRollback(con)
# } else {
#   dbCommit(con)
# }
# 
# dbClearResult(rs)
# dbDisconnect(con)
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace