Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Begin Transaction
Message
De
19/09/2002 04:38:01
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Begin Transaction
Divers
Thread ID:
00702151
Message ID:
00702151
Vues:
52
Hi,
I am using buffering and transaction for sales module. Once a sales transaction completed, record will be added to sales table, lineitems table and also deduct stock qty from stock_status table.

Here is my code:
*-- Insert record to sales table
*-- Insert lineitems records to lineitem table
*-- Replace stock_status.qty with stock_Status - qtysold for each items
*-- Increase auto number

BEGIN TRANSACTION

IF NOT llRollBack AND NOT TABLEUPDATE(.T., .F., "Sales")
   llRollBack = .T.
ENDIF

IF NOT llRollBack AND NOT TABLEUPDATE(.T., .F., "lineitems")
   llRollBack = .T.
ENDIF

IF NOT llRollBack AND NOT TABLEUPDATE(.T., .F., "Stock_status")
   llRollBack = .T.
ENDIF

IF NOT llRollBack AND NOT TABLEUPDATE(.T., .F., "AutoNo")
   llRollBack = .T.
ENDIF

IF llRollBack
   AERROR(laError)

   ROLLBACK
   TABLEREVERT(.T., "sales")
   TABLEREVERT(.T., "lineitems")
   TABLEREVERT(.T., "stock_status")
   TABLEREVERT(.T., "autono")

   RETURN laError[2]
ELSE
   END TRANSACTION
   RETURN "OK-"
ENDIF
I faced problem that, if there are any unexpected disaster occured such as power failure and system hang the "TRANSACTION" is not work correctly.
It sometime save the records partially which meant, the stock qty is deducted, autono is increased but sales and lineitems is not committed.

Any ideas?

Thank you
I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform