MS SQL: wrapping updates to several tables in one LOGOUT / COMMIT / ROLLBACK, as with TPS

Applies to: any Clarion version with the MSSQL driver (the SoftVelocity MSSQL driver is ODBC-based, as the thread notes); SQL Server 2005 and later. Earlier SQL Server versions were not covered by the posters.

Problem

Can several MS SQL tables be wrapped in one transaction the way TPS files are?

Relate:File1.UseLogout = false   ! individual logout off
Relate:File2.UseLogout = false
LOGOUT(4,File1,File2)
! do the work
IF Access:File1.TryUpdate() OR Access:File2.TryUpdate()
  ROLLBACK
ELSE
  COMMIT
END

Solution

  1. Yes, the shape above works on MS SQL (Jon W., Dennis E.). Both updates fall inside the one transaction because the Access methods issue no LOGOUT/COMMIT of their own (the Relate methods do) and UseLogout = false switches off the per-update logout. The ABC TransactionManager template does the same thing.
  2. The list of files in the LOGOUT does not matter on SQL: one table on the connection starts the transaction for that connection, extra files do no harm (Jon W., Dennis E.).
  3. Keep the transaction short. Work that only changes Clarion-side buffers goes before the LOGOUT; only database operations belong between LOGOUT and COMMIT (Jon W.). Never wait for user input inside it.
  4. Without a LOGOUT every single update, insert or delete is its own implicit transaction on SQL Server: it is committed or rolled back by itself. If update 1 succeeds and update 2 fails, only update 2 is rolled back (Dennis E.).

Caveats

  • A LOGOUT / COMMIT around each row in a loop is row-by-agonizing-row processing; a few dozen rows nobody notices, but inserts get painfully slow as the count grows. Do not design SQL work that way (Dennis E.).
  • The driver manages transactions at the connection level, the way ODBC does; the details are on MSDN and are worth reading, though typically not an issue (Dennis E.).
  • The original poster's question about MS SQL "pitfalls" got the answer that the transactions themselves work; any problem would be on the application side, not in the backend.

Today (2026)

Unchanged in principle: LOGOUT on an SQL driver still opens one transaction per connection and the Relate/Access split is the same in ABC. Not re-measured.

Sources: Kurt P. (Apr 2012, the question), Jon W., Dennis E. (Apr 2012) in softvelocity.clarion.databasedrivers.