Databases Reference
In-Depth Information
Table 13-1.
Optimistic Locking Scenario
Step
Mina
Natalie
Edit
P1_EMPNO
1
--
Edit
P1_EMPNO
2
--
3
Edit help text to: “Mina's Help”
--
4
--
Edit help text to: “Natalie's Help”
5
Apply changes
--
6
--
Apply changes
7
--
Receive error message:
Current version of data in database has changed since user
initiated update process. Current row version identifier =
"A08A505E601932E33BC1074BEA1A3B4C" application row version
identifier = "AECE767E4BDDC737A7823083A31D564F"
Contact your application administrator.
Optimistic locking only works when developers modify the same object. The problem occurs when multiple
developers are modifying different objects on the same page at the same time. Modifying one object may affect the
process of the entire page, which other developers may not be aware of.
Pessimistic locking
helps prevent trouble in
that scenario. The next section discusses how to do pessimistic locking.
Locking an APEX Page
The easiest way to prevent issues from occurring when developing an application with multiple developers is to
lock a page before working on it. Locking a page prevents other developers from modifying the page while you're
working on it. Developers can still view the page and its components while a page is locked; they just can't make any
modifications to the page.
The following process locks a page:
1.
On the
Page Edit
screen, click the
Lock
icon in the upper-right corner, as shown in
Figure
13-1
.
Figure 13-1.
Locking a page
2.
You see a report of page locks with a filter for the current page (page 2 in this example).
Select the check box for the current page, and then click the
Lock Checked
button.
3.
Enter a value for
Comment
(all page locks require a comment), and click
Lock Page(s)
.
4.
You're brought back to the
Page Locks
report, where you see the current page marked
as locked.