Hi,
I am developing POS and inventory system. How could I make sure data accuracy in application during sales and stock deduction in Multiuser mode?
I am using table buffering in my module.
I have the following code in my module. I am not sure that my code can guarantee the accuracy of stock amount.
Since i am using buffering, after I doing UPDATE-SQL (which will minus the current stock balance with sales item count), the stock balance may be changed by other user before I issue TABLEUPDATE().
How to guarantee the balance is accurate?
Thank you
USE salestable AGAIN SHARED IN 1
CURSORSETPRO("buffering", 5)
USE stocktable AGAIN SHARED IN 2
CURSORSETPRO("buffering", 5)
UPDATE stocktable SET stockbalance = stockbalance - salesItemCount
WHERE stockID = itemID
BEGIN TRANSACTION
IF alltableOK
END TRANSACTION
ELSE
ROLLBACK
ENDIF
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...