Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Begin Transaction, tableupdate..
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00745129
Message ID:
00745285
Vues:
20
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform