Transaction does not hang if it cannot obtain a lock - FOR UPDATE ... NOWAIT - Oracle Transaction

Q.  To ensure that a transaction does not hang if it cannot obtain a lock, which of the following statements below should be executed?
- Published on 13 Aug 15

a. UPDATE ... NOWAIT
b. FOR UPDATE ... WAIT
c. FOR UPDATE ... NOWAIT
d. UPDATE ... WAIT

ANSWER: FOR UPDATE ... NOWAIT
 

    Discussion

  • Nirja Shah   -Posted on 22 Sep 15
    - Whenever a session is waiting on a transaction, a rollback to savepoint does not free row locks.

    - To make sure a transaction does not hang if it cannot obtain a lock, use FOR UPDATE ... NOWAIT before issuing UPDATE or DELETE statements.

    - This refers to locks obtained before the savepoint to which has been rolled back.

    - Row locks obtained after this savepoint are released, as the statements executed after the savepoint have been rolled back completely.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)