Home » SQL & PL/SQL » SQL & PL/SQL » Optimistic locking (Oracle 9.2.0.3)
Optimistic locking [message #404675] Fri, 22 May 2009 14:25 Go to next message
prachij593
Messages: 266
Registered: May 2009
Senior Member
Can anyone show a demo of optimistic locking? Using TCN an additional column.

Thanks
Re: Optimistic locking [message #404676 is a reply to message #404675] Fri, 22 May 2009 14:28 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
www.orafaq.com/papers/locking.pdf
Re: Optimistic locking [message #404680 is a reply to message #404676] Fri, 22 May 2009 15:01 Go to previous message
prachij593
Messages: 266
Registered: May 2009
Senior Member
Thomas kyte provided the below good example in his book
SQL> variable deptno number
SQL> variable dname varchar2(14)
SQL> variable loc varchar2(20)
SQL> variable last_mod varchar2(50)
SQL> begin
2 :deptno := 10;
3 select dname, loc, last_mod
4 into :dname,:loc,:last_mod
5 from dept
6 where deptno = :deptno;
7 end;
8 /
PL/SQL procedure successfully completed.



User 1:
SQL> update dept
2 set dname = initcap(:dname),
3 last_mod = systimestamp
4 where deptno = :deptno
5 and last_mod = to_timestamp_tz(:last_mod);
1 row updated.


user 2:
SQL> update dept
2 set dname = initcap(:dname),
3 last_mod = systimestamp
4 where deptno = :deptno
5 and last_mod = to_timestamp_tz(:last_mod);
0 row updated.

Thanks..

[Updated on: Fri, 22 May 2009 15:03]

Report message to a moderator

Previous Topic: Order Ascending or Descending based on condition
Next Topic: how to get the first row of record ?
Goto Forum:
  


Current Time: Fri Dec 09 21:15:52 CST 2016

Total time taken to generate the page: 0.25056 seconds