Selecting Records For Update
When you enter a SELECT command to query database records, no locks are placed on the selected records, and other database users can use view and update these records at the sane time you are viewing them. This is necessary databases with the many concurrent users.
However, records that have been changed with an INSERT or UPDATE statement are locked until the user holding the lock releases it by issuing a COMMIT or ROLLBACK command.
Sometimes you might want to view a record and then update it in the same transaction.
You must be able to view the quantity on hand and then update it in a single transation. This can be achieved by using SELECT FOR UPDATE command in oracle.
The SELECT FOR UPDATE command palces a shared lock on the record, which means that other users can view the data but con not update or delete the data.
SELECT column1, column2, …
FROM table1, table2, …
WHERE search and join conditions
FOR UPDATE OF column1, column2, …
NOWAIT;
The NOWAIT command instructs Oracle to not wait if the selected record is currently locked by another user. It is used for the DELETE and UPDATE command.

Leave a Reply