SET LOCKTYPE
Purpose
Determines whether locking strategies should be optimistic or pessimistic
Syntax
SET LOCKTYPE TO OPTIMISTIC | PESSIMISTIC
See Also
CHANGE(), GATHER, LOCKR, READ, REPLACE, RLOCK()
Description
The SET LOCKTYPE set command is used to determine the locking strategy when a record is updated via temporary field placeholders such as memory variables or array elements. The default Recital behavior is SET LOCKTYPE TO PESSIMISTIC. With LOCKTYPE set to PESSIMISTIC, the record must be locked (RLOCK() or LOCKR) throughout the transaction to ensure that it cannot be modified by another user before the update is made. Without a lock being placed, the state of the data cannot be guaranteed.
With LOCKTYPE set to OPTIMISTIC, then prior to a REPLACE or GATHER operation the record is compared to the buffer from the previous read. If the two differ, an error is generated and the update does not take place. The CHANGE() function can be used to check whether the record has been modified before issuing the REPLACE or GATHER commands.
Example
set locktype to optimistic use customer store automem @1,1 get m.name @2,1 get m.address @3,1 get m.state read if not change() replace customer.name with m.name,; customer.address with m.address,; customer.state with m.state endif
Products
Recital Server, Recital