Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BEGIN-END Transaction question
Message
De
19/06/2004 15:14:07
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
19/06/2004 11:29:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00915326
Message ID:
00915378
Vues:
10
>Perhaps I am not being clear. You have multiple users creating debits to accounts.
>
>Everywhere I allow a debit to be created I must:
>
>Lock the account
>   get the account balance
>
>   while balance < debit amount
>      allow reducing debit amount
>   loop
>
>   if debit is < balance
>      post the debit
>   endif
>unlock the account
>
>
>If I am going to do the above, I must also check for a locked account, when I attempt to lock an account.
>Something like this:
>
>
>If attempt lock
>   if not successful
>      ask user if they want to retry or give up
>   endif
>endif
>
You can call it "error handling" or whatever you like, however, you don't need traditional error handling (ON ERROR or TRY). Just combine the two above, as follows:

>
* Lock the account
if lock()
   get the account balance

   while balance < debit amount
      allow reducing debit amount
   loop

   if debit is < balance
      post the debit
   endif
   select account table
   unlock the account
else
   MessageBox("Another user is working with this account. Please try again later.")
endif
>
IOW, since lock() returns. .T. or .F., depending on success, no additional error-handling functions are required.

HTH,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform