Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

explicit locking

Mostafa AbolaynainJan 14 2013 — edited Feb 8 2013
Hi All

I have a button on a form, when this button is clicked it should read a value from the form and sum it to the total value in a table , here are the steps for When-button-pressed trigger :

1- Read the total issued quantity form the master table and lock the row :
select ISSUED_QTY INTO V_LOCK_QTY
from stopen
where STOCK_CODE=:ISSLINES.STOCK_CODE
for update NOWAIT;


2- Add the value in the form to issued_qty colum in that table:


UPDATE STOPEN
SET ISSUED_QTY=NVL(ISSUED_QTY,0)+NVL(:ISSLINES.QTY,0)
where STOCK_CODE=:ISSLINES.STOCK_CODE;


I used the for update clause to lock the row that was read in step 1 and will be updated in step 2 to make sure that no other user can update that row untill the current user update it and commit (or rollback).

My question is :
1- Is this type of locking is suitable to this situation ?
2- How can I Handle the exception if that row was locked by another user ? by a message with 2 options (wait or exit the trigger).
3- How can I lock the row for a limited time ,I tried to write : for update WAIT 5, but forms cosidered it as syntax error.


Thanks in advance
Mostafa
This post has been answered by Andreas Weiden on Jan 15 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2013
Added on Jan 14 2013
10 comments
1,187 views