16.10.2015 Views

Getting Started with DB2 Express-C

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13 – Concurrency and Locking 219<br />

13.3.3 Non-repeatable read<br />

A non-repeatable read implies that you cannot obtain the same result after performing the<br />

same read in the same operation.<br />

Figure 13.6 – Non-repeatable Read<br />

In Figure 13.6, consider if you are trying to book a flight from Dallas to Honolulu. The<br />

sequence of events is:<br />

1. App1 opens a cursor (also known as a result set) obtaining what you see in Figure 13.6<br />

2. App2 deletes a row that qualified for the cursor (for example, the row <strong>with</strong> destination<br />

“San Jose”)<br />

3. App2 commits changes<br />

4. App1 closes and reopens the cursor<br />

In this case, since App1 would not get the same data on a repeated read, it cannot<br />

reproduce the data set; that’s why this problem is called “non-repeatable read”.<br />

13.3.4 Phantom read<br />

The phantom read problem is similar to the non-repeatable read problem, but the<br />

difference is that on subsequent fetches, you may obtain additional rows rather than fewer<br />

rows. Figure 13.7 provides an example of this problem.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!