1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
% $Id: dbCommit-methods.Rd,v 0.1 2008/08/10 18:04:01 psk Exp $
\name{dbCommit-methods}
\docType{methods}
\alias{dbBegin-method}
\alias{dbCommit-method}
\alias{dbRollback-method}
\alias{PostgreSQLConnection-method}
\alias{dbBegin,PostgreSQLConnection-method}
\alias{dbCommit,PostgreSQLConnection-method}
\alias{dbRollback,PostgreSQLConnection-method}
\title{
DBMS Transaction Management
}
\description{
Transaction related commands.
Start a transaction, commit or roll back the current transaction
in an PostgreSQL connection.
\code{dbBegin} starts a transaction.
\code{dbCommit} and \code{dbRollback} commit and rollback the
transaction, respectively.
}
\section{Methods}{\describe{
\item{conn}{a \code{PostgreSQLConnection} object, as produced by the function
\code{dbConnect}.}
\item{\dots }{currently unused.}
}
}
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or
\url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
\code{\link[DBI]{dbBegin}},
\code{\link[DBI]{dbConnect}},
\code{\link[DBI]{dbSendQuery}},
\code{\link[DBI]{dbGetQuery}},
\code{\link[DBI]{fetch}},
\code{\link[DBI]{dbCommit}},
\code{\link[DBI]{dbGetInfo}},
\code{\link[DBI]{dbReadTable}}.
}
\examples{\dontrun{
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="postgres")
dbGetQuery(con, "select count(*) from sales")
dbBegin(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)
}else{
dbCommit(con)
}
dbGetQuery(con, "select count(*) from sales")
dbDisconnect(con)
}
}
\keyword{methods}
\keyword{interface}
\keyword{database}
% vim: syntax=tex
|