[DB][DB2] SKIP LOCKED DATA

the logical session locking approach to database locking

apessimistic session locking approach has been difficult to implement.
but, with the new feature SKIP LOCKED DATA introduced in DB2 Version9.1 for z/OS, an easy and reliable solution is possible.

for a solution,
it is suggested that you define a DB2 table holding a list of resource identifiers (index) and use a lock/unlock protocol in all applications accessing the resouces.
the implementation of the lock() function exploits the new DB2 capabilities of skipping locked data in a SQL fetch statement.

CREATE TABLE HOGEGE_TBLE (COL_ID CHAR(10));
INSERT INTO HOGEGE_TABLE VALUES('IDX01');
INSERT INTO HOGEGE_TABLE VALUES('IDX02');

the feature SKIP LOCKED DATA is exploited to get only rows that are not locked by DB2.
DB2 does not wait on the fetch operation.

DECLARE C1 CURSOR FOR
SELECT COL_ID FROM HOGEGE_TABLE WHERE COL_ID =: parameter
FOR UPDATE WITH CS SKIP LOCKED DATA;
OPEN C1;
FETCH C1;

ref:
Use DB2 Version 9.1 for z/OS to implement application session locking, 01 Feb 2007
http://www.ibm.com/developerworks/data/library/techarticle/dm-0702kempfert/index.html

tag : DB2 SKIP LOCKED DATA

2009-05-19 06:20 : 開発 : コメント : 0 : トラックバック : 0 :
コメントの投稿
非公開コメント

« next  ホーム  prev »

search

ad



counter


tag cloud

category cloud