Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BEGIN-END Transaction question
Message
From
19/06/2004 15:14:07
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
19/06/2004 11:29:51
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00915326
Message ID:
00915378
Views:
11
>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)
Previous
Reply
Map
View

Click here to load this message in the networking platform