Synergex.SynergyDE.Select.Event

Event class onLock method override

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
namespace Synergex.SynergyDE.Select
public class Event

The Event class object includes event override methods that allow you to extend the class.

Methods

onLock

public virtual method onLock, boolean
    inout lock,   n
    inout wait,   n
    in rec,       a
    in rfa,       a
proc
    mreturn false
endmethod

Traps a “Record is locked” error (LOCKED) issued during a Select iteration. This method is called with the current lock and wait settings, as well as a copy of the record that was locked and its GRFA. If onLock() is not implemented, false is returned and a LOCKED error is generated.

lock

A LOCK qualifier lock_spec value (see LOCK) or Q_NO_DELETE (which is a lock mode to use during a call to Select.Delete() to allow a retry without deleting the locked record). (n)

wait

A WAIT qualifier wait_spec value. (See WAIT.) (n)

rec

Returned with the record that was locked. (a)

rfa

Returned with the RFA location of the record. If this RFA will be used to re-establish the record after the Select has completed, we recommend the file use static RFAs. (a)

Discussion

To trap a LOCKED error during a Select iteration, you must implement your own event class that extends the Select.Event class and overrides the onLock() method. Returning false from your onLock() method (which occurs if it is not implemented) allows a LOCKED event to be caught by your onLock() method and then resumed as if the event were not caught. Conversely, implementing the method and simply returning true tells the Select iteration to retry the operation that caused the event.

In addition, by altering the lock and wait flags, you can control how the operation handles the retry. For example, by setting lock to Q_NO_LOCK and returning true, the Select iteration can resume by skipping the locked record. During a Select.Delete() call, you can use Q_NO_DELETE to skip the deletion of a locked record.

The onLock method is not supported by Join, since no records are locked during a Join iteration.

Examples

class lockEvent extends Event
  public static waited, boolean
  public override method onLock, boolean	
    inout lock, n
    inout wait, n
    in rec, a
    in rfa, a
  record
    retry  ,boolean
  proc
    retry = true
    if (.not.waited) then
      begin
        xcall DisplayWaitMsg()
        wait = 5
        waited = true
      end
    else
      begin
        retry = %ReportLock(rec, rfa);
        if (retry)
          lock = Q_NO_LOCK
      end
    mreturn(retry)
  end
endclass