Transaction
Demarcate or manage a JDBC transaction.
Component Signature
Attributes
action
string
false
When used inside a transaction block, perform some action upon an existing transaction. One of: begin
, commit
, rollback
, or setsavepoint
.
begin
isolation
string
false
The isolation level to use for the transaction. Can only be set upon transaction begin. One of: read_uncommitted
, read_committed
, repeatable_read
, or serializable
.
savepoint
string
false
The name of the savepoint to set or rollback to. Used with savepoint
or rollback
actions.
nested
boolean
false
Whether or not this transaction is nested within another transaction. Default is false
.
false
datasource
string
false
The name of the datasource to use for the transaction. If not provided, the first query execution inside the transaction will set the datasource.
Examples
Simple Transaction
A "simple" transaction might look like this:
Note that you can specify a custom isolation level using the isolation
attribute on the component:
Nested Transaction
BoxLang supports nested transactions, using savepoints to control transaction state between the parent and child transactions.
Here, we have a nested transaction that may (or may not) error; if this happens we want to roll back the logging query but NOT roll back the user query. This functions the same as if we were rolling back to a named savepoint created just after the UPDATE users
query.
Script Syntax
Tag Syntax
Last updated
Was this helpful?