16.10.2015 Views

Getting Started with DB2 Express-C

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13 – Concurrency and Locking 235<br />

This SELECT hangs waiting for the exclusive (X) lock to be released by the <strong>DB2</strong><br />

Command Window #1 application. As you can see, the default behavior of CS<br />

prior to <strong>DB2</strong> 9.7 allows for less concurrency<br />

From <strong>DB2</strong> Command window #2:<br />

CTRL-C (press these keys to interrupt)<br />

Close the window<br />

From <strong>DB2</strong> Command window #1:<br />

db2 rollback<br />

Close the window<br />

Procedure 2: Analyze the behavior of isolation CS <strong>with</strong> currently committed<br />

1. Turn currently committed to ON:<br />

Open a <strong>DB2</strong> Command Window and issue:<br />

db2 update db cfg for sample using CUR_COMMIT on<br />

db2 force applications all<br />

Close the window.<br />

2. Open two <strong>DB2</strong> Command Windows as in part 1 so one is on top of the other. Then<br />

issue the following:<br />

From <strong>DB2</strong> Command window #1:<br />

db2 connect to sample<br />

db2 +c update staff set name = 'Chong' where id = 10<br />

From <strong>DB2</strong> Command window #2:<br />

db2 connect to sample<br />

db2 +c select * from staff<br />

Now this SELECT statement works! .It does not hang, and the value displayed is<br />

Sanders, which is the currently committed value.<br />

From <strong>DB2</strong> Command window #1:<br />

db2 rollback<br />

Close the window.

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

Saved successfully!

Ooh no, something went wrong!