5 Transactions

Many data sources support the use of transactions. In order to use this capability from BetaDBC, the fragment transactions must be included. An outline of the interface of this fragment is shown below. The full interface may be seen in the interface section.

transactionsSupported:
  (# isSupported: @boolean
  ...
  exit isSupported
  #);
autoCommitMode:
  (# autoCommit: @boolean
  enter (#  enter autoCommit ... #)
  exit (# ... exit autoCommit #)
  #);
readUncommitted: integerValue (# ... #);
readCommitted: integerValue (# ... #);
repeatableRead: integerValue (# ... #);
serializable: integerValue (# ... #);
transactionLevelSupported: booleanValue
  (# level:  @integer
  enter level
  ...
  #);
transactionLevel:
  (# level: @integer
  enter (#  enter level ... #)
  exit (# ... exit level #)
  #);
commit: (#  ... #);
rollBack: (#  ... #)

The scope of a transaction is a whole connection including all statements allocated in it. The default is that every execution of an SQL statement starts a new transaction and automatically commits the effects of this statement after the statement has completed. This auto commit mode may be changed to manual commit mode by evaluating

false->sqlCon.autoCommitMode

where sqlCon is an instance of a connection. Note that this is only meaningful if transactionsSupported evaluates to true. In manual commit mode a series of database manipulations may be committed by executing commit. Equivalently a series of database manipulations may be aborted by executing rollBack.

Four transaction isolation levels (as defined in the SQL standard) are available, namely readUncommitted, readCommitted, repeatableRead, and serializable. Whether a transaction isolation level, such as serializable, is supported in a given connection may be checked by evaluating e.g.

serializable->sqlCon.transactionLevelSupported


The BetaDBC Library - Reference Manual and Tutorial
© 1999-2004 Mjølner Informatics
[Modified: Friday September 7th 2001 at 12:45]