4D v16.3SET QUERY AND LOCK |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
SET QUERY AND LOCK
SET QUERY AND LOCK
The SET QUERY AND LOCK command can be used to request the automatic locking of records found by all queries that follow the calling of this command in the current transaction. This means that the records cannot be modified by a process other than the current process between a query and the handling of results. By default, the records found by queries are not locked. Pass True in the lock parameter to activate locking. It is imperative for this command to be used within a transaction. If it is called outside of this context, an error is generated. This allows for better control of record locking. The records found will stay locked as long as the transaction has not been terminated (whether validated or cancelled). After the transaction is completed, all the records are unlocked. The records are locked for all the tables in the current transaction. When a SET QUERY AND LOCK(True) statement has been executed, the query commands (for example QUERY) adopt a specific functioning if a record that is already locked is found:
Consequently, in this context it is necessary to test the LockedSet set after a fruitless query (current selection empty and/or OK variable set to 0) in order to determine the cause of the failure. Call SET QUERY AND LOCK(False) in order to disable this mechanism afterward. SET QUERY AND LOCK only modifies the behavior for query commands, in other words:
However, SET QUERY AND LOCK does not affect other commands that modify the current selection such as ALL RECORDS, RELATE MANY, etc. In this example, it is not possible to delete a client who would have been passed from category “C” to category “A” in another process between the QUERY and DELETE SELECTION commands:
START TRANSACTION If the command is not called in the context of a transaction, an error is generated.
See also
|
PROPERTIES
Product: 4D HISTORY
Created: 4D v11 SQL ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||