Difference between revisions of "SET LOCKTYPE"

From Recital Documentation Wiki
Jump to: navigation, search
Line 1: Line 1:
=SET LOCKTYPE=
 
 
 
 
==Class==
 
==Class==
 
Manual Locking
 
Manual Locking
Line 15: Line 12:
  
 
==See Also==
 
==See Also==
[[GATHER]], [[READ]], [[REPLACE]], [[CHANGE()]]
+
[[CHANGE()]], [[GATHER]], [[LOCKR]], [[READ]], [[REPLACE]], [[RLOCK()]]  
  
  
Line 25: Line 22:
  
 
==Example==
 
==Example==
<pre>set locktype to optimistic
+
<code lang="recital">
 +
set locktype to optimistic
 
use customer
 
use customer
 
store automem
 
store automem
Line 33: Line 31:
 
read
 
read
 
if not change()
 
if not change()
replace customer.name with m.name,;
+
    replace customer.name with m.name,;
customer.address with m.address,;
+
      customer.address with m.address,;
customer.state with m.state
+
      customer.state with m.state
endif</pre>
+
endif</code>
  
  

Revision as of 14:33, 16 April 2009

Class

Manual Locking


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 Database Server, Recital Mirage Server, Recital Terminal Developer