Skip to main content

RollbackTran

procedure RollbackTran;

Example

procedure ScriptEvent(var Value: Variant);
begin
if DBCon = nil then
raise Exception.Create('No database connection is available');
DBCon.RollbackTran;
Value := False;
end;

Usage

RollbackTran rolls back and ends the current SQL transaction when transactions are enabled and one is active.

Behaviour

No return value identifies whether rollback occurred. It affects database changes enlisted on the same transaction/connection; it cannot undo already committed work or filesystem, email, HTTP and other external effects.

Errors and quirks

  • No active transaction produces a silent no-op.
  • A pre-existing transaction can be rolled back even when this script's StartTransaction call was a no-op.
  • Transaction-disabled configuration makes this method a no-op, but DisconnectDatabase still calls the SQL connection's rollback path before disconnecting.
  • If Velox cannot obtain the connection, the call can fail with an object-reference error. Database and driver rollback errors are raised to the script.

Additional Technical Info

RollbackTran cancels changes in and ends the transaction currently held by this DB connection wrapper.

Implementation

Runtime registration maps to native vxRollbackTran. With transactions enabled, it obtains SQLDATA and calls VxRollbackTran, which invokes Delphi DBX RollbackFreeAndNil only when InTransaction is true. It logs a SQL rollback comment only when an actual transaction was rolled back.

Performance and concurrency

Rollback can block while the database reverses work and releases locks. Keep one explicit owner for the transaction boundary.

Related entries

External references

Created 2026-07-15