# rollback work statement

The rollback work statement rolls back
(or undoes) a transaction.

## Syntax

```
rollback work {then|else statement.block}
```

## Description

This operation automatically
undoes all updates made since the last begin work statement. All locks acquired within the transaction are released.

## Example(s)

```
open "myfile" to f1
open "mylog" to f2
begin work
write total on f2,timedate();* create synchronized log
readu total from f1,"total"
if total = 0 then
 rollback work;* Cannot do anything
end else
 total = total - 1
 write total on f1,"total"
 commit work else print "Could not update"
end
```

## See also

- [begin work statement](https://d3codex.com/pickbasic-flashbasic/begin-work-statement/)
- [transaction abort statement](https://d3codex.com/pickbasic-flashbasic/transaction-abort-statement/)
- [transaction commit statement](https://d3codex.com/pickbasic-flashbasic/transaction-commit-statement/)
- [transaction rollback function](https://d3codex.com/pickbasic-flashbasic/transaction-rollback-function/)
- [_CP_trans](https://d3codex.com/cfunctions/cp-trans/)

---
Source: https://d3codex.com/pickbasic-flashbasic/rollback-work-statement/ - part of the D3Codex reference.
