Begin Transaction, End Transaction, Rollback, TxnLevel()
The transaction commands let you combine updates to a group of tables into a single process so all the changes either happen or don't happen. Transactions can be nested—TXNLEVEL() lets you find out how deep you are.
Usage |
BEGIN TRANSACTION END TRANSACTION ROLLBACK nCurrentLevel = TXNLEVEL() |
Example |
* Save invoice header and details in a transaction. * This is only a sketch of the real code, which would * probably include various error checking and handling. BEGIN TRANSACTION lGoOn = .T. SELECT header IF NOT TABLEUPDATE() lGoOn = .F. ENDIF IF lGoOn SELECT detail IF NOT TABLEUPDATE(.t.,.t.) lGoOn = .F. ENDIF ENDIF IF lGoOn END TRANSACTION ELSE ROLLBACK =TABLEREVERT(.f.,"header") =TABLEREVERT(.t.,"detail") ENDIF |
See Also |
Buffering, SQLCommit(), SQLSetProp(), SQLRollback(), TableRevert(), TableUpdate() |