User Tools

Site Tools

Navigation:  Language Reference > 13 - Built-in Functions >====== WATCH (automatic concurrency check) ====== Previous pageReturn to chapter overviewNext page

WATCH( entity )


WATCH Arms automatic optimistic concurrency checking.
entity The label of a FILE or VIEW declaration.

The WATCH statement arms automatic optimistic concurrency checking by the file driver for a following GET, REGET, NEXT, or PREVIOUS statement in a multi-user environment. The WATCH terminates when the WATCHed record is PUT back to the entity, or another GET, NEXT, PREVIOUS, or REGET statement executes on the same entity without first executing another WATCH statement.

Generally, the file driver retains a copy of the retrieved record on the GET, NEXT, PREVIOUS, or REGET when it successfully gets the record. When the retrieved record is PUT to the file, the record on disk is compared to the original record retrieved. Error 89 (Record Changed By Another Station) is posted by the PUT statement if the record has been changed by another user.

You can now specify which fields are to be used to WATCH if a record has changed. By default all fields are used. However, if you have a specific field (or set of fields) that are always changed when a record is changed (e.g., a record last changed a timestamp field), then you can set the external name of the field to:

<;FieldName> | WATCH

and then only fields with the WATCH switch in them will be used to check if a record has changed.


SET(Itm:InvoiceKey)                     !Start at beginning of Items file

LOOP                                    !Process all records

WATCH(Items)                           !Arm concurrency check

NEXT(Items)                            !Get a record


DO ItemProcess                         !process the item

PUT(Items)                             !and put it back

IF ERRORCODE() = RecordChangedErr      !If changed by another station

 PREVIOUS(Items)                       !Setup to re-process the changed record


 STOP(ERROR())                         !Stop on any other error



See Also:






watch_automatic_concurrency_check_.htm.txt · Last modified: 2021/04/15 15:57 by