Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transactions
Message
From
04/05/2002 20:52:19
 
 
To
03/05/2002 05:45:36
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00648654
Message ID:
00652841
Views:
29
>>
>>If I understand:
>>I don't think there is any way that a user can detect the TXNLEVEL() of another user. One wat to prevent another user from BEGIN TRANSACTION in the middle of your Transaction, is to lock all the files that will be updated before starting to Update.
>>
>>llUpdate = .T.
>>DO WHILE !FLOCK(t1) or !FLOCK(t2) or !FLOCK(t3) or !FLOCK(t4) or !FLOCK(t5)
>>  IF INKEY() = 27    &&Escape pressed
>>    llUpdate = .F.
>>    EXIT
>>  ENDIF
>>ENDDO
>>IF llUpdate
>>  BEGIN TRANSACTION
>>    ..... (Update process here)
>>  END TRANSACTION
>>ENDIF
>>UNLOCK ALL
>>
>
>
>
>Situation A:
>Yes, but how can the transaction work correctly in situation when update code is located in same object than BEGIN TRANSACTION and END TRANSACTION in multi-user environment? One of the users will get his updates done and the others get rollback and an messagebox I have programmed to pop up when tableupdates fail and rollback is done. It works just so that I planned it.
>
>Situation B
> When the update code is located in another object,the code will work (tables get their updates as long as there's no errors), but there is no transaction, although I have started it with BEGIN TRANSACTION and txnlevel() returns more than 0. There's no rollbacks and no messageboxes. The code is exactly similar with Situation A,but the code is located on different objects. The users only get update conflicts and partial updates.
>
>I don't know can I explain this clear enough...
>But if you come up with something, please share.
>
>Thanks,

I don't think I understand your situation. I will try, but it this is wrong, try again.

Situation A:
It sounds like you're trying to get the Transaction to regulate attempts to save data by more than one user at a time. The Transaction itself cannot do that. The transaction is a way for the INDIVIDUAL USER to Rollback if something goes wrong (power going out before done, finding a locked file, etc.) As long as nothing goes wrong, then the INDIVIDUAL USER issues END TRANSACTION and the physical drive is updated in as short a period as possible.
An object would have to read some change on the drive to determine if another user is currently running a transaction. IOW each user would set some kind of flag on the hard drive (like locking a file) right before BEGIN TRANSACTION. Every other user would try and lock the same file before they began a transaction, since they couldn't lock it, they would not start their transaction.



Situation B:
It looks like you are trying to read a TXNLEVEL() from a different DATASESSION than the one that BEGIN TRANSACTION.
If an object does BEGIN TRANSACTION, then the system switches to a different object (that has a PRIVATE DATASESSION) the 2nd object will not see there is a transaction started.
Define Form-A as Form
  DataSession = 2    && private
Form-A.TxnBegin()
  BEGIN TRANSACTION
  ? TXNLEVEL()       && returns 1
  RETURN
Form-A.TxnEnd()
  END TRANSACTION
  RETURN

Define Form-B as Form
Form-B.SomeMethod()
  Form-A.TxnBegin()
  ? TXNLEVEL()       && returns 0 -- even though Form-A started a transaction
  ..... process data
  Form-A.TxnEnd()
Form-B will not see the Transaction started in Form-A. If you make Form-A DataSession=1 then Form-B will see the Transaction.
Bill Morris
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform