473,792 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

soft lock problem

hi, we are using db2 udb v8.1 ESE with type 4 jcc driver. since DB2
can't support pessimistic locking , and our application required that,
which means when both users try to access the same record with intent
to update, the first one grab the record will create a row lock on the
current row reading, before it update, other user can't access the
same record with intent for update read, but can access with read only
type. so when the first user update the row, it will release the row
lock and let the other user with intent for update read to grab the
record. In order to do this, i think i can't use transaction and
isolation level control by the database, db2 support only optimistic
locking ,isn't it? so i think might need to use column locking (soft
lock), which means with extra column like timestamp, but the
disadvantage is when power off, some one who create the lock will
leave the flag there and when server start again, i have to clean up
all thousands tables timestamp column to start over, does anyone has
any idea how to do it efficiently? thanks
Nov 12 '05 #1
1 3602
Xixi,

My understanding is that optimistic lockis what you want and pessimistic
locking is what DB2 does.
Try this (not validated)

CREATE TABLE T(pk not null primary key, c1 INTEGER, version INTEGER)
;
CREATE TRIGGER trg1 NO CASCADE BEFORE UPDATE ON T OF (version)
REFERENCING NEW AS n OLD AS o FOR EACH ROW MODE DB2SQL
SET n.version = CASE WHEN n.version = o.version
THEN -n.version
ELSE raise_error('38 000', 'version mismatch')
END
;
-- trg2 must be defined after trg1!
CREATE TRIGGER trg2 NO CASCADE BEFORE UPDATE ON T
REFERENCING NEW AS n OLD AS o FOR EACH ROW MODE DB2SQL
SET n.version = CASE WHEN n.version = -o.version
THEN n.version + 1
ELSE raise_error('38 001',
'version not specified')
END
;
CREATE TRIGGER trg3 NO CASCADE BEFORE INSERT ON T
REFERENCING NEW AS n FOR EACH ROW MODE DB2SQL
SET n.version = 1
;

SELECT c1, version INTO v_c1, v_version FROM T WHERE pk = 5;
.....
UPDATE T SET c1 = v_c1, version = v_version WHERE pk = 5;
....
From CLI you can also use optimistic locking through scrollable cursors.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

383
12272
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a poor man's DBMS, a broken email server and various other /application/ servers to try and crack the Internet and IS markets. In the case where they didn't spend their own money to get companies to
6
3541
by: Mark | last post by:
Hi, My page has a table with many columns such that the right-side of the table gets chopped off when printed. I specify a table width of 100%, but otherwise no cell dimensions are specified. The culprits are 2 wide columns which contain e-mail addresses. I can get the page to fit entirely on the printer output if the browser would break the e-mail address string at the '@' symbol. What I've done for now is replaced the '@' in all...
1
3349
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ... www.soft30.com/download-1-11975.htm - 31k - Cached - Similar pages MDBSecure 1.0.8.0 - Soft30.com Utility which makes it easy to create secure MS Access Databases, ... MS Access 2000/2003 format. 30 day money back guarantee, 30 day trial. ...
0
17820
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico Mariani, performance architect for the Microsoft® .NET runtime and longtime Microsoft developer, mentioned to Dr. GUI in an e-mail conversation recently that a fairly common practice (and one that's, unfortunately, described in some of our...
4
3813
by: tbatwork828 | last post by:
Related to my other post on Graphics.FillRectangle and a lot of page faults caused by this call... We determine that when Control.DoubleBuffer=true to avoid the flicker effect, Graphics.FillRectangle causes a lot of soft page faults - order of 700/sec and more... When Control.DoubleBuffer=false, we have no page faults at all - 0/sec. Has anyone seen this behavior and how did they resolve it...? What are our options...? Does...
0
2971
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the list athe result is that the standard (QWERTY) keyboard appears. I found that many ( all?) ISV's who make IM's have customers reporting this problem. My research on the internet brought me to the conclusion it is some
1
1369
by: call_me_anything | last post by:
I sometimes wonder how rapidly all the soft junk is increasing in today's world. Look at the number of mails getting piled up, CVS histories and log files, message groups' collosum of info etc. Will it not create a huge mess of data whose management will some day pose a serious problem to the soft-world ? Are there any plans to stop the soft-pollution ? How dangerous can it be ?
0
1150
by: paulvz882 | last post by:
comprimes de acomplia en France commander acomplia en ligne aucune prescription acomplia canada soft en ligne +++ PERTE DE POIDS +++ PERTE DE POIDS +++ PERTE DE POIDS +++ + ACHETER DU ACOMPLIA BON MARCHE (ALL CARDS ACCEPTED) http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia +
0
1361
by: jkjtjktjktjhktjk | last post by:
acheter du acomplia cinq acomplia par email PERTE DE POIDS en France acomplia canada soft en ligne acomplia belgique acomplia belgique bon marche acheter du acomplia en ligne sur internet +++ PERTE DE POIDS +++ PERTE DE POIDS +++ PERTE DE POIDS +++ + ACHETER DU ACOMPLIA BON MARCHE (ALL CARDS ACCEPTED) http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia...
0
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.