LOCK Statement(lock_statement) Locate the document in its SAP Library structure

The LOCK statement assigns a lock to the current Structure linktransaction (see Structure linklock).

Syntax

<lock_statement> ::=
LOCK [(WAIT)|(NOWAIT)] <lock_spec> IN SHARE MODE
LOCK [(WAIT)|(NOWAIT)] <lock_spec> IN EXCLUSIVE MODE
LOCK [(WAIT)|(NOWAIT)] <lock_spec> IN SHARE MODE <lock_spec> IN EXCLUSIVE MODE
LOCK [(WAIT)|(NOWAIT)] <row_spec>... OPTIMISTIC

<lock_spec> ::= TABLE <table_name>,... | <row_spec>...
| TABLE <table_name>,... <row_spec>...

row_spec, table_name

Explanation

The specified table cannot be a base table, a view table (see table), nor a synonym. If the table name identifies a view table, locks are set on the base tables on which the view table is based.

WAIT/NOWAIT

<row_spec>...

A <row_spec>... creates a lock for the table row denoted by the key values or a position in a result table.

Specifying a row_spec requires that the specified table have a key column; that is, if the table name identifies a view table, this must be modifiable.

TABLE <table_name>,...

If TABLE <table_name>,... is specified, a lock is created for the table in question.

If the view table identified by the table name is not changeable, only a Structure linkshare lock can be set for this view table. As a result of this SQL statement, share locks are set for all base tables underlying the view table.

SHARE

SHARE defines a Structure linkshare lock for the listed objects. To set share locks, the current user must have the SELECT privilege.

EXCLUSIVE

EXCLUSIVE defines an Structure linkexclusive lock for the listed objects. To set exclusive locks, the current user must have the UPDATE, DELETE, or INSERT privilege.

OPTIMISTIC

OPTIMISTIC defines an Structure linkoptimistic lock on rows. This is only meaningful in connection with Structure linkisolation levels Structure link0, Structure link1, 10, and Structure link15.

Deadlock

Whenever the database system recognizes a deadlock caused by locks, it ends the transaction with an implicit ROLLBACK WORK.

Reproducibility

If reproducible results are needed to read rows using a select statement, the read objects must be locked and the locks must be kept until reproduction. Reproducibility usually requires that share locks are set for the tables concerned, either by explicitly locking them using one or more lock statements, or implicitly by using the Structure linkisolation level 3. This ensures that other users cannot modify the table.

See also:

Structure linkLock Behavior