>I want to write a small classlib that will handle tableupdates.
>My idea starts something like this:
>
>
>
>lPARAMETERS llUseTransaction, aTableUpdateArray
>
>IF llUseTransaction = .T.
> BEGIN TRANSACTION
>ENDIF
>
>lnNumberOfTables = ALEN(aTableUpdateArray, 1)
>
>FOR lnCounter = 1 TO lnNumberOfTables
> lcTableUpdateName = aTableUpdateArray[lnCounter, 1]
> llTableUpdate = TABLEUPDATE(2, .F., &lcTableUpdateName, aUpdateError)
>
>
>The questions I have are this:
>1. Is there a way to determine if you're already in a transaction?
You can do a validation using TxnLevel()
>2. When using the tableupdate() command this way, if the lcTableUpdateName is a remote view, how should the code look if the command fails?
> Begin Transaction
> ....then llTableUpdate = .F. ....
> TableRevert(&lcTableUpdateName)
> Rollback
> End Transaction
>
>...I guess I'm asking if I need both the tablerevert & Rollback if Im inside a transaction...
Basically, yes you need both (all samples in VFP help always include both) especially if you use "Table Buffering". But it also depend on what you need.
VFP help remarks
-----------------
ROLLBACK restores the original tables, table memo files, and index files to the state they were in before the transaction began.
----------------
So if some data has been changed before the transaction, you need to revert it after rollback. Again, it is your decision to make a revert or not.
Just an idea :)
HTH
Herman