transactions: Transaction support

Description Usage Arguments Details Value Author(s) Examples

Description

Start, commit or rollback transactions or savepoints

Usage

1
2
3
4
5
6
7

Arguments

savepoint

an object produced by savepoint

Details

These functions allow manipulation of database transaction states. If no savepoint object is supplied, then an attempt is made to commit or rollback the current transaction.

The savepoint function will initiate a transaction if one is not currently active. In that case, no actual PostgreSQL savepoint will be used. Rolling back the savepoint will rollback the initiated transaction. If a tranaction is active, then a named savepoint will be generated. You can rollback to the database state when savepoint was called or commit all changes.

Value

savepoint: a savepoint object

Author(s)

Timothy H. Keitt

Examples

 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
## Not run: 
createdb("rpgtesting")
connect("rpgtesting")
begin()
sp1 = savepoint()

# nest savepoints
sp2 = savepoint()
data(mtcars)
write_table(mtcars, "testtab", overwrite = TRUE)
list_tables()
rollback(sp2)

list_tables()
# nest savepoints
sp3 = savepoint()
sp4 = savepoint()
write_table(mtcars, "testtab", overwrite = TRUE)
commit(sp4)
list_tables()
rollback(sp3)
list_tables()

rollback(sp1)
rollback()
disconnect()
dropdb("rpgtesting")
## End(Not run)

thk686/rpg documentation built on Sept. 5, 2019, 11:13 p.m.