Difference between revisions of "SET LOCKTYPE"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=SET LOCKTYPE=
 
 
 
==Class==
 
Manual Locking
 
 
 
 
==Purpose==
 
==Purpose==
 
Determines whether locking strategies should be optimistic or pessimistic
 
Determines whether locking strategies should be optimistic or pessimistic
Line 15: Line 8:
  
 
==See Also==
 
==See Also==
CHANGE(), GATHER, READ, REPLACE
+
[[CHANGE()]], [[GATHER]], [[LOCKR]], [[READ]], [[REPLACE]], [[RLOCK()]]
  
  
Line 25: Line 18:
  
 
==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 27:
 
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>
  
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 +
[[Category:Documentation]]
 +
[[Category:Commands]]
 +
[[Category:Set_Commands|LOCKTYPE]]
 +
[[Category:Manual Locking]]
 +
[[Category:Manual Locking Set Commands]]

Latest revision as of 16:10, 23 November 2009

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