Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transaction
Message
From
19/09/2002 04:38:01
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Begin Transaction
Miscellaneous
Thread ID:
00702151
Message ID:
00702151
Views:
51
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...
Next
Reply
Map
View

Click here to load this message in the networking platform