Transaction and Buffer Scope

daranroo7

New Member
Hi,
I was trying to understand the transaction scope at par with buffer scope. Below is the code which i tried out.
Def var vname like customer.custname no-undo.
update vname.
**************
Procedure proc1:
define buffer bcust for customer.
Do transaction:
find first bcust exclusive-lock no-error.
if avail bcust then
assign bcust.custname = "Daniel".
End.
Release bcust.
End procedure.
******************Procedure proc2:
define buffer bcust for customer.
Do for bcust transaction:
find first bcust exclusive-lock no-error.
if avail bcust then
assign bcust.custname = "Daniel".
End.
End procedure.

As per the above code,
Proc1 releases the lock and make others to use after the procedure(proc1) but raises the scope of bcust buffer to entire procedure.
Proc2 releases the lock and restricts the scope of buffer to the proc2 procedure only.

Among the two, i understand proc2 is the best way to do. But though scope is raised to whole procedure by proc1, the buffer is still available for others to update ..so this should be ok right ? how exactly scope2 makes better result compared to scope1?

Thanks and Regards,
Daniel Ranjit.R
 
Among the two, i understand proc2 is the best way to do. But though scope is raised to whole procedure by proc1, the buffer is still available for others to update ..so this should be ok right ? how exactly scope2 makes better result compared to scope1?

In proc1 the buffer is only available for update after the transaction block ends and not before that.
 
Top