Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BEGIN-END Transaction question
Message
De
19/06/2004 10:16:58
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
BEGIN-END Transaction question
Divers
Thread ID:
00915326
Message ID:
00915326
Vues:
41
I have 2 apps accessing and updating a single database.

The database is the main database for an app titled ITF.

The apps:
ITF is used to maintain accounts just like your bank maintains it's customers accounts.
POS is a point of sale app used to create sales transactions that will be used to deduct from accounts mainted by ITF.

The ITF app has functionality that allows it's users to increase account balances (deposits), and decrease account balances (charge an account for any of a number of things).

The POS app, runs on mobile (i.e. like laptops), PC's. These POS PC's have a drive mapping to the location of the ITF app's database. FYI: The POS app has a views database that contains views that access the ITF app's database. The ITF app's database is NOT included in the POS app's project.

POS has it own database and tables. POS only accesses ITF's database at the beginning of a sale, to get the customer's current balance and at the end of the sale, to post the sales transaction.

My question has to do with the end of the sale. To be more exact, it has to do with ensuring the sale amount, is less than the current balance. It is not valid for a sale to be posted which results in a negative account balance.

Here is what I do in the POS app:

get current balance
while current balance < sale amount
use POS app to modify sale, reducing sale amount to < current balance
get current balance
loop

&& At this point, the sale amount is < current balance

BEGIN TRANSACTION
save sale transaction (there are several tables updated)
END TRANSACTION

I realize the above is not good enough. Why? A user of the ITF app could deduct money from the same account (the one the sale is being posted to), AFTER I have determined the sale amount is less than the current balance but before the sale is actually posted.

If it looked more like this, it would work (I think):

BEGIN TRANSACTION
get current balance
while current balance < sale amount
use POS app to modify sale, reducing sale amount to < current balance
get current balance
loop

save sale transaction (there are several tables updated)
END TRANSACTION

BUT, I beleive the BEGIN...END TRANSACTION locks tables so I would be allowing user intervention between a lock...unlock. NEVER a good idea.

My question: How to accomplish this?

NOTE: I really do NOT want to have a field in the account record that get's set True/"the account is locked" before getting the balance and set False/"the account is unlocked" after the save. I have seen this before and inevitable the system goes down and the "lock" is left in place.

Thanks,
John
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform