Re: Recordlocking in Forms

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 19 Jan 2000 13:47:40 -0500
Message-ID: <ib1c8s0e02i3ugu0a2gjop8lmoomee7c7p_at_4ax.com>


A copy of this was sent to plant.eng_at_lund.mail.telia.com (if that email address didn't require changing) On Wed, 19 Jan 2000 18:28:07 GMT, you wrote:

>Hi.
>Is there anyone who knows how recordlocking works in Forms?
>Or any document describing the mechanics?
>
>We have Forms application and we also write applications in other
>environments (VB, Excel, C++)
>We would like to use the same record locking for all applications so
>they would correctly interact with Forms and with eachother, when users
>are atempting to access the same record in the database.
>
>Thanks Tony.

forms will select the row out -- unlocked. it will modify your query to also select out either the ROWID or PRIMARY KEY (if you haven't already). Lets say you built a block on "ename, hiredate, sal" for the EMP table. Forms would execute "select ename, hiredate, sal, ROWID from emp".

The first time the user goes to UPDATE a record on the screen (before they actually type over the value) forms will execute logic similar to the following:

for i in 1 .. 3

     select * 
       from emp
      where ROWID = :block.ROWID
        and ename = :block.ENAME
        and hiredate = :block.HIREDATE
        and sal = :block.SAL
     FOR UPDATE NOWAIT;

    if we got zero rows back from the SELECT     then

        return with the error "sorry, your data has changed, please requery"
        -- this means that either the row has been deleted by another session
        -- OR someone updated the ENAME, HIREDATE, or SAL fields of your record
    end if;

    if we got resource busy
    then

        do nothing, retry 3 times to see if record becomes available
        -- this means another session is in the process of updating
        -- this record right now...

    end if;

    return OK -- successful record lock; end loop

return with the error "Sorry, record is locked, please try again later" -- we tried 3 times and got resource busy so let them know....       

-- 
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
 
Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation
Received on Wed Jan 19 2000 - 19:47:40 CET

Original text of this message