Documentation

Home > Documentation > LOCK/UNLOCK Statement

LOCK/UNLOCK Statement

Syntax

LOCK lockset_identifier ON {field_identifier | expression}[, ...]
  FROM stream_identifier_i

Syntax

UNLOCK lockset_identifier ON {field_identifier | expression}[, ...]
  FROM stream_identifier

Substitutable Fields

lockset_identifier:

A unique identifier (name) for a lockset previously defined through the CREATE LOCKSET statement.

field_identifier:

The unique identifier (name) for a tuple field that is a component of the lock.

expression:

An expression that is a component of the lock.

stream_identifier:

The stream that passes into LOCK or UNLOCK and from which the lock key values needed to obtain or release a lock are extracted. This stream is unaltered by passage through LOCK or UNLOCK.

Discussion

In the LOCK and UNLOCK statements, lockset_identifier names the lock set (previously declared in a CREATE LOCKSET statement) that will manage the lock. The field_identifier or expression entries following the ON clause are the input stream tuple fields or values that identify the lock. The number and types (but not necessarily the names) of the entries following the ON clause must match the number and type (but not necessarily the names) of the fields in the lock set.

The FROM clause entry, stream_identifier, is the name of the input stream. Like the table stream queries, the LOCK and UNLOCK statements do not identify the output stream that will "capture" their output. LOCK and UNLOCK generate a stream and may be used anywhere a stream expression is acceptable. Alternatively, the output could be "captured" in a stream, as illustrated in the following code fragment.

CREATE [OUTPUT] STREAM stream_identifier;
LOCK ... INTO stream_identifier;

Or

CREATE [OUTPUT] STREAM stream_identifier;
UNLOCK ... INTO stream_identifier;