tags:

views:

121

answers:

1

with in do transaction, i defined a label and in this label i am accessing a table with exclusive-lock.and at the end of label i have done all the changes in that table. bt now i am with in transaction block. Now, i tried to access that same table in another session.then it show an error, Table used by another user. So is it possible that, can we release teh table with in transaction,so another user can access it. Exe Session1)

DO TRANSACTION:


loopb:

repeat:

-- ---------------------> control is here right now. end. /repeat/

--

end /do transaction/ Session2)

I tried to access same table,bt it show an error,that table locked by another user.

+3  A: 

All those records you touched in the loop using EXCLUSIVE-LOCK will not be available to be locked by another user until the TRANSACTION is complete. There is no getting around this. If the second process needs to lock those records, then all you can do is decrease your TRANSACTION scope in the first process. This is a safety feature so that if an error happens later on in the TRANSACTION, all the changes made during the TRANSACTION will be rolled back. Another way to look at it is if you could release some record locks during a TRANSACTION, you would lose the atomicity (all-or-nothingness) that is part of the definition of a TRANSACTION.

It should be noted that if you don't really need to lock those records in the second process but just need to see their updated value, that is possible. Once the updated records are no longer in the record buffer (or the record lock status is downgraded to a NO-LOCK in the TRANSACTION), they will become limbo locks and you can view their updated values using a NO-LOCK. To make the last record in the loop become a limbo lock, you can either do this

FIND CURRENT tablerecord NO-LOCK.

Or this, if you do not need to access the record buffer any longer:

RELEASE tablerecord.
AbeVoelker
Thanks Abe, but i want to update the same record in session two which is hold in session one.But i can not decrease my transaction size because it will effect anothe conditions.So is their any oyther alternate that i can also update my records in second session.
jay
Jay, updating the record in the second session requires an EXCLUSIVE-LOCK on the record, which is being held by the first session and will not be released until the end of the TRANSACTION.The only way you can accomplish what you are trying to do is 1) narrow your TRANSACTION scope as mentioned in my answer or 2) take the record locking code in session one and make the updates happen in an external session, for instance by using a stateless AppServer call.
AbeVoelker
Abe, I can narrow my Transaction scope bcz it require a lot of changs. I think second option is good.I'll try this second.But i have tried to use external procedure(with out calling AppServer) for updating second session record.Table was still in locked.
jay
Jay, that is because the external procedure call is still happening within the same session (same stack space), and it inherits the calling procedure's TRANSACTION. Using the AppServer is your best bet. You may want to include the TRANSACTION DISTINCT keyword on the RUN statement when calling the AppServer, since in the future Progress has noted that they may make transactions propagate to the AppServer by default (this phrase will not make any difference currently).
AbeVoelker
Thanks Abe, I done this by reducing the transaction scope.
jay
Glad I could answer your question! You can mark your question as 'answered' by clicking the checkbox to the left of my answer.
AbeVoelker