dbCommit-methods {RPostgreSQL} | R Documentation |
Commits or roll backs the current transaction
in an PostgreSQL connection.
dbBeginTransaction
starts a PostgreSQL transaction.
dbCommit
and dbRollback
commit and rollback the
transaction, respectively.
PostgreSQLConnection
object, as produced by the function
dbConnect
.
See the Database Interface definition document
DBI.pdf
in the base directory of this package
or
http://stat.bell-labs.com/RS-DBI.
PostgreSQL
,
dbConnect
,
dbSendQuery
,
dbGetQuery
,
fetch
,
dbCommit
,
dbGetInfo
,
dbReadTable
.
## Not run: drv <- dbDriver("PostgreSQL") con <- dbConnect(drv, dbname="postgres") dbGetQuery(con, "select count(*) from sales") dbBeginTransaction(con) rs <- dbSendQuery(con, "Delete * from sales as p where p.cost>10") if(dbGetInfo(rs, what = "rowsAffected") > 250){ warning("Rolling back transaction") dbRollback(con) } dbGetQuery(con, "select count(*) from sales") dbDisconnect(con) ## End(Not run)