In Oracle AI Database 26ai the WAIT and NOWAIT clauses are available for all main DML statements: INSERT, UPDATE, DELETE and MERGE.
They let an application decide what to do when a DML statement tries to modify a row that is already locked by another transaction:
NOWAIT – fail immediately instead of waiting for the lock.
WAIT n – wait for the specified time and fail if the row is still locked.
WAIT FOREVER – keep the traditional Oracle behavior and wait indefinitely.
This makes lock handling explicit at statement level and avoids changing a session-wide setting.
Syntax
INSERT ... NOWAIT;
INSERT ... WAIT 5 SECONDS;
UPDATE ...
WHERE ...
WAIT 500 MILLISECONDS;
DELETE ...
WHERE ...
WAIT 2 SECONDS;
MERGE ...
WHEN MATCHED THEN ...
WHEN NOT MATCHED THEN ...
WAIT FOREVER;
The supported time units are SECONDS, MILLISECONDS and MICROSECONDS. If the unit is omitted, Oracle uses seconds.
If neither clause is specified, the statement keeps the default behavior and waits indefinitely for the row lock.
Continue reading →