WITH-TRANSACTION — Execute a body of code within a transaction.Macro
database
A database object. This will default to the value of *default-database*.
body
A body of Lisp code.
result
The result of executing body
.
Starts a transaction in the database specified by
database
, which is
*default-database* by default, and executes
body
within that transaction. If
body
aborts or throws,
database
is rolled back and otherwise the
transaction is committed.
(in-transaction-p) => NIL (select [email] :from [employee] :where [= [emplid] 1] :flatp t :field-names nil) => ("lenin@soviet.org") (with-transaction () (update-records [employee] :av-pairs '((email "lenin-nospam@soviet.org")) :where [= [emplid] 1])) => NIL (select [email] :from [employee] :where [= [emplid] 1] :flatp t :field-names nil) => ("lenin-nospam@soviet.org") (in-transaction-p) => NIL
Changes specified in body
may be made
to the underlying database if body
completes successfully.