UNLOCK

Release a record lock on a channel

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
UNLOCK channel[, RFA:match_rfa]

Arguments

channel

The channel on which the file is open. (n)

RFA

(optional) Unlocks the record with the specified RFA. See RFA for a complete description.

Discussion

Using the UNLOCK statement on an ISAM file unlocks either the specified RFA or the automatic lock (if RFA is not specified). Usually RFA:match_rfa specifies a manual lock, but an automatic lock will also be unlocked if present. UNLOCK RFA on a non-ISAM file ignores the specified RFA and simply unlocks the automatic lock.

On Windows and UNIX, manual locks must be released individually using RFA, or they will be released all together when the file is closed.

On OpenVMS, if the VMS_UNLOCK_SINGLE environment variable is set (and system option #35 is not set), the UNLOCK statement (without RFA specified) on an indexed or relative file will unlock only the last record.

If system option #35 is set, the UNLOCK statement removes all locks on the specified channel, regardless of whether or not VMS_UNLOCK_SINGLE is set. If no lock conditions exist on the specified channel, UNLOCK is ignored.

See also

Examples

The following subroutine unlocks either automatic or manual locks depending on whether the RFA is passed.

subroutine rel_locks
    a_chn               ,n
    a_rfa               ,a
proc
    if (^passed(a_rfa)) then
      unlock a_chn, RFA:a_rfa
    else
      unlock a_chn
    xreturn
endsubroutine

The following example reads and locks a relative record, and then prompts the user to add a new record, change the locked record, delete the locked record, or exit the routine. If the user selects exit or presses the EOF character, the ­record is explicitly unlocked.

subroutine proc_rec
    a_chn               ,d              ;Channel of file open in update mode
    a_data              ,a              ;Data record to read
    a_recnum            ,d              ;Record number to read
.define TTCHN           ,1
record
    ans                 ,a1
proc
    read(a_chn, a_data, a_recnum) ;Record locked
    repeat
      begin
        display(TTCHN, "Add/Change/Delete/Exit: ")
        reads(TTCHN, ans, exit)
        case ans of
          begincase
          "A":
            xcall add
          "C":
            xcall change
          "D":
            xcall delete
          "E":
            exitloop
          endcase
      end
exit,
    unlock a_chn
    xreturn
endsubroutine