Applies to: Clarion 6.x with the MSSQL driver (as reported, 2006); MS SQL Server.
Problem
The program ran SELECT NextTransNo FROM SysFile, then built a second statement, UPDATE SysFile SET NextTransNo = plus the value plus one. Can this be one statement, and how do you stop two users reading the same number between the two calls?
Solution
Ranked by the thread:
- A stored procedure that sets the isolation level to serializable, begins a transaction, selects the value into an output parameter, updates the row and commits. The poster who proposed it called it the better choice. The Clarion help covers calling stored procedures and output parameters, and the details depend on the version.
- Set the isolation level through PROP:IsolationLevel and run the work inside a transaction.
- A batch in one statement:
select nexttransno from sysfile;update sysfile set nexttransno = nexttransno+1, to be run in a serializable transaction. - With no transaction at all, sooner or later two users get the same number.
Caveats
- One poster said separate statements cannot form a transaction. A later poster disagreed: BEGIN TRAN issued through PROP:SQL creates your own transaction outside the Clarion LOGOUT / COMMIT, and he attached a small project against the Northwind database; he said it also works on Oracle. The attachment is not in the archive text.
UPDATE ... SET NextTransNo = (SELECT NextTransNo FROM SysFile) + 1updates but does not return the value.- An Oracle-only remark: the
returningkeyword can give the value back.
Today (2026)
Not re-tested. The isolation-level reasoning is general SQL and likely holds; try the BEGIN TRAN route on your driver before relying on it.
Sources: Scott R. (Jan 2006, the question), Jim K., Brian S., Arnor B., Rick M. (Jan 2006) in softvelocity.clarion.databasedrivers.