Re: Usage of RowId... -- optimistic locking
Date: 1998/04/16
Message-ID: <01bd68e1$f70d0d80$2207030a_at_sahmad-pc.mfa.com>#1/1
Consider table tab1
Forms or PowerBuilder or whatever ...
Create a centralized routine say AFTER_STORE, that does the following
if ( sqlcode_from_oracle != 0 )
then
if sqlcode = -200001
show_message_to_user ( package.msg [from PL/SQL package] )
end if
rollback;
else
commit;
endif
Scenerio 1 - Update was supposed to succeed
Retrieve the data for a PK value ( say the u_version was 10 and PK PK1 )
Update it on the form
Store it (implying that client software issues the actual update
statement)
- before row fires, stores in the pl/sql array PK1/10
- <does whatever else the trigger was supposed to do>
- after statement eventually fires
- table queried and the u_version was still 10, so make it 11 call AFTER_STORE
Scenerio 2 - Update was supposed to fail Retrieve data for PK value (u_version 11, PK PK1) Update it on the form
In another session retrieve PK value ( u_version 11, PK PK1) Update Store (u_version now 12 because of triggers) commit Store iterror
- before row saves PK1/11 in the array
- after statement queries tab1 and sees that value is 12 now so raise
AFTER_STORE will show the message and rollback
Summary
The triggers seem to be a lot of work, but they can be generated quite easily and latest versions
of Oracle (7.3.4 or 8) do allow for multiple triggers on same event. So the creation of the triggers
should not pose a huge problem.
Some FrontEnd softwares may already allow optimistic locking, but the
trigger approch has the
potential advantage of working with all technologies.
Received on Thu Apr 16 1998 - 00:00:00 CEST