Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make sure data accuracy?
Message
 
 
To
02/01/2001 09:56:22
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00458440
Message ID:
00458474
Views:
19
Two things to consider.

1. Use views. If the underlying table data changes before you issue yor tableupdate, the tableupdate will fail and you can trap for this.
2. Add "and stockbalance = stockbalance" to the WHERE clause. This way, if someone else does change the underlying data, then your Update statement will not find a match. You can check to see if your record was updated by checking the _Tally system variable after the statement. If it equal to 0, then you know the update statement found nothing.

HTH.

>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)
>
>**do watever to search records
>UPDATE stocktable SET stockbalance = stockbalance - salesItemCount
>     WHERE stockID = itemID
>
>BEGIN TRANSACTION
>
>** update all table
>
>IF alltableOK
>   END TRANSACTION
>ELSE
>   ROLLBACK
>   **REVERT ALL CHANGES
>ENDIF
>
>
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform