KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Testing for success: SET QUERY AND LOCK
PRODUCT: 4D | VERSION: 11.2 | PLATFORM: Mac & Win
Published On: January 7, 2009

4D v11 SQL Release 2 introduces commands to lock the entire selection of records for subsequent queries:

SET QUERY AND LOCK

Testing for success of these commands is a bit more complex than it might seem. Remember:


  • Locks records for the duration of the current transaction.

  • If a query fails (did not lock all records) the current selection will be emptied.

    • However, the current selection may also be empty because the query did not return any results.



  • If a query fails, 4D creates a locked records set ("LockedSet").

    • The locked set only contains one record: namely the first locked record encountered.



  • Therefore, to test for success, you need to check OK and the locked set. For example:




    If ((OK=1) & (Records in set("LockedSet")=0))

    ` The SET QUERY AND LOCK succeeded.