PreviousNextIndex

CURRENT-CHANGED function

Returns TRUE if the copy of the record in the buffer after executing a FIND CURRENT or GET CURRENT differs from the copy of the record in the buffer before executing the FIND CURRENT or GET CURRENT. That is, if the current application changes the record, but no other user changes the record during its scope in the current application, CURRENT-CHANGED returns FALSE.

Syntax

CURRENT-CHANGED record 

record
Example

The following example finds the first customer record with NO-LOCK and makes it available to the user to review and change:

r-currch.p
FORM Customer.Name Bustomer.Balance WITH FRAME upd. 
ON GO OF FRAME upd DO: 
  DO TRANSACTION: 
    FIND CURRENT Customer EXCLUSIVE-LOCK. 
    IF CURRENT-CHANGED Customer THEN DO: 
      MESSAGE "This record has been changed by another user" SKIP 
        "Please re-enter your changes." VIEW-AS ALERT-BOX. 
      DISPLAY Customer.Name Customer.Balance WITH FRAME upd. 
      RETURN NO-APPLY.  
    END. 
    ASSIGN Customer.Name Customer.Balance. 
  END. 
  FIND CURRENT Customer NO-LOCK. 
END. 
FIND FIRST Customer NO-LOCK. 
DISPLAY Customer.Name Customer.Balance WITH FRAME upd. 
DO ON ENDKEY UNDO, LEAVE: 
  ENABLE Customer.Name Customer.Balance WITH FRAME upd. 
  WAIT-FOR "GO" OF FRAME upd. 
END. 

While the user reviews the record, other users can change it. After the user makes a change of their own and enters GO in the frame, the first FIND CURRENT statement refetches the current customer record with an EXCLUSIVE-LOCK (preventing other users from reading or updating it). Then, the CURRENT-CHANGED function compares the contents of the customer record with the copy of the customer record that was in the buffer before the FIND CURRENT statement. If it differs, the CURRENT-CHANGED function returns a TRUE value, prints a message, and displays the contents of the customer record contained in the buffer. The RETURN NO-APPLY option prevents the program from ending and gives the user another chance to change the customer record.

The CURRENT-CHANGED function returns a FALSE value if the copy of the customer record that is in the buffer was not modified. After verifying that the copy of the record has not changed, the ASSIGN statement updates the customer record and a second FIND CURRENT statement down grades the record to NO-LOCK. Thus, while the user has ample time to review and change the record, the actual transaction time is kept to a minimum to allow other users access.

Notes
See also

FIND statement, GET statement, LOCKED function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex