UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

Example In the following example, the transaction process aborts if var is 0: 1-875 UniBasic Commands Reference TRANSACTION START THEN PRINT "Transaction started." ELSE PRINT "Transaction start failed, STATUS = ":STATUS(): STOP READU var FROM file.var, record1 var += 2 IF var = 0 THEN TRANSACTION ABORT; GOTO ERR: WRITE var TO file.var, record1 TRANSACTION COMMIT THEN PRINT "Transaction committed." ELSE PRINT "Transaction Aborted, STATUS = ":STATUS(); STOP Related Commands UniBasic TRANSACTION COMMIT, TRANSACTION START

TRANSACTION COMMIT Syntax TRANSACTION COMMIT {THEN statements [END] | ELSE statements [END]} Description The UniBasic TRANSACTION COMMIT command concludes the active transaction. UniData writes all pending writes to the appropriate files. You must specify a THEN clause or an ELSE clause. You can specify both clauses. UniData performs the following steps during a transaction commit: Disables the interrupt key. Writes all updates. Releases all record locks locked inside the transaction. Executes the THEN clause if it exists. Enables the interrupt key. Warning: When including WRITE statements within a transaction, you must code an ON ERROR clause that takes appropriate action to notify the user and stop the transaction. If the transaction is not aborted by the ON ERROR clause, processing continues, and the transaction will commit inappropriately. TRANSACTION COMMIT 1-876

Example<br />

In the following example, the transaction process aborts if var is 0:<br />

1-875 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

TRANSACTION START<br />

THEN PRINT "Transaction started."<br />

ELSE PRINT "Transaction start failed, STATUS = ":STATUS(): STOP<br />

READU var FROM file.var, record1<br />

var += 2<br />

IF var = 0 THEN TRANSACTION ABORT; GOTO ERR:<br />

WRITE var TO file.var, record1<br />

TRANSACTION COMMIT<br />

THEN PRINT "Transaction committed."<br />

ELSE PRINT "Transaction Aborted, STATUS = ":STATUS(); STOP<br />

Related <strong>Commands</strong><br />

<strong>UniBasic</strong><br />

TRANSACTION COMMIT, TRANSACTION START

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!