Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin... End Transaction mystery
Message
From
17/05/2007 00:23:09
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Begin... End Transaction mystery
Miscellaneous
Thread ID:
01226239
Message ID:
01226239
Views:
100
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
Next
Reply
Map
View

Click here to load this message in the networking platform