Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin... End Transaction mystery
Message
From
17/05/2007 07:31:22
 
 
To
17/05/2007 00:23:09
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01226239
Message ID:
01226259
Views:
38
First, what's the setting of SET REPROCESS? Try to set it at -1 or AUTOMATIC.

Second, it's normal that you receive the File is in use error because (from the help on BEGIN TRANSACTION): When you modify records in a table that is part of a transaction, other users on the network do not have access (read or write) to the records until you end the transaction. Since you keep locking the records in a loop on a computer, the other one can't access it. In a normal course of action, you would keep open the transaction for the smallest amount of time to prevent collision.

HTH

>I tried to understand how the Begin...End Transaction works, I wrote a small looping program, what I found is quite a mystery for me.
>
>this is my code:
>
>
>set multilocks on
>tryAgain=0
>
>for nloop=1 to 10
>
>  do while .t.
>
>    select tableA
>    replace...
>    select tableB
>    replace...
>    insert into tableC...
>
>    begin transaction
>
>    allOk=.n.
>    select tableA
>    if tableupdate(.t.)
>       select tableB
>       if tableupdate(.t.)
>          select tableC
>          if tableupdate(.t.)
>             allOK=.y.
>          endif
>       endif
>    endif
>
>    if allOk
>       end transaction
>    else
>       rollback
>       tryAgain=tryAgain+1
>       if tryAgain<3
>          wait window 'Rollback but try again '+str(tryAgain)
>          loop
>       endif
>       wait window 'Rollback and go next' timeout 5
>    endif
>
>  wait window 'pause for 5 seconds, how many loop:'+str(nloop) timeout 5
>  exit
>  enddo
>
>next nloop
>
>
>I started the app in 2 PCs, after the third loop, PC #1 got an error:
>
>
>File is in use by another user.
>
>
>then Rollback
>while it keep looping but always rollback, even the other PC has finished the looping and exit.
>
>PC #1 keep showing:
>
>
>Rollback but try again 1
>Rollback but try again 2
>Rollback and go next
>pause for 5 seconds, how many loop: 3
>Rollback but try again 1
>Rollback but try again 2
>Rollback and go next
>pause for 5 seconds, how many loop: 4
>
> ... and so on until the last loop
>
>is there any explanation for this? how to release the lock? what's wrong with my code?
>
>thanks for the help
Previous
Reply
Map
View

Click here to load this message in the networking platform