473,394 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SELECT ... FOR UPDATE not locking rows

Hello.

We have a multi-user Java application that can connect to either a
UniVerse database or a DB2 database on an AS400 through JDBC. The
program executes a SELECT ... FOR UPDATE statement. When connected to
the UniVerse database, if a second user runs the program, at the point
where the selection executes, the program waits on the lock until the
first user's updates are committed. However, when connected to the DB2
database, in the same situation, execution proceeds as if the FOR
UPDATE were not there.

Any ideas on what I should be looking for? Thanks.

Mar 21 '07 #1
3 28583
jb*********@sbcglobal.net wrote:
Hello.

We have a multi-user Java application that can connect to either a
UniVerse database or a DB2 database on an AS400 through JDBC. The
program executes a SELECT ... FOR UPDATE statement. When connected to
the UniVerse database, if a second user runs the program, at the point
where the selection executes, the program waits on the lock until the
first user's updates are committed. However, when connected to the DB2
database, in the same situation, execution proceeds as if the FOR
UPDATE were not there.

Any ideas on what I should be looking for? Thanks.
See the definition of update-clause here:
http://publib.boulder.ibm.com/infoce...zmstintsel.htm

Excerpts:
"The UPDATE clause identifies the columns that can be updated in a
subsequent positioned UPDATE statement."
"When FOR UPDATE is used, FETCH operations referencing the cursor
acquire an exclusive row lock."

--
Karl Hanson
Mar 21 '07 #2
On Mar 21, 3:17 pm, Karl Hanson <kchan...@youess.ibm.comwrote:
jbutler8...@sbcglobal.net wrote:
Hello.
We have a multi-user Java application that can connect to either a
UniVerse database or a DB2 database on an AS400 through JDBC. The
program executes a SELECT ... FOR UPDATE statement. When connected to
the UniVerse database, if a second user runs the program, at the point
where the selection executes, the program waits on the lock until the
first user's updates are committed. However, when connected to the DB2
database, in the same situation, execution proceeds as if the FOR
UPDATE were not there.
Any ideas on what I should be looking for? Thanks.

See the definition of update-clause here:http://publib.boulder.ibm.com/infoce...ndex.jsp?topic...

Excerpts:
"The UPDATE clause identifies the columns that can be updated in a
subsequent positioned UPDATE statement."
"When FOR UPDATE is used, FETCH operations referencing the cursor
acquire an exclusive row lock."

--
Karl Hanson
Thanks. I'm not sure this is the exact solution you were pointing me
toward, but adding an isolation clause WITH RR to the select when
connected to DB2 did the trick.

Mar 21 '07 #3
On Mar 21, 9:08 pm, jbutler8...@sbcglobal.net wrote:
On Mar 21, 3:17 pm, Karl Hanson <kchan...@youess.ibm.comwrote:


jbutler8...@sbcglobal.net wrote:
Hello.
We have a multi-user Java application that can connect to either a
UniVerse database or a DB2 database on an AS400 through JDBC. The
program executes a SELECT ... FOR UPDATE statement. When connected to
the UniVerse database, if a second user runs the program, at the point
where the selection executes, the program waits on the lock until the
first user's updates are committed. However, when connected to the DB2
database, in the same situation, execution proceeds as if the FOR
UPDATE were not there.
Any ideas on what I should be looking for? Thanks.
See the definition of update-clause here:http://publib.boulder.ibm.com/infoce...ndex.jsp?topic...
Excerpts:
"The UPDATE clause identifies the columns that can be updated in a
subsequent positioned UPDATE statement."
"When FOR UPDATE is used, FETCH operations referencing the cursor
acquire an exclusive row lock."
--
Karl Hanson

Thanks. I'm not sure this is the exact solution you were pointing me
toward, but adding an isolation clause WITH RR to the select when
connected to DB2 did the trick.- Hide quoted text -

- Show quoted text -
Hi,

Did this really do the trick?

The reason I ask is that we have also experienced deadlocks between
two instances of the same code that uses a cursor to ensure the record
is locked prior to any processing.

The row is identified using the PK of the table, so only one row is
ever identified and hopefully locked and tracing confirms that both
processes were using the same primary key. My understanding of the FOR
UPDATE clause and FETCH, was that one process would wait for the
other, however DB2 does not appear to behaving this way (at least not
in v8.2.5 anyway).

You may have solved our problem if it is true.

Regards,
Paul.

Mar 27 '07 #4

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

Similar topics

0
by: Andy Jackman | last post by:
Hi, I want to get any one of a number of rows that matches some criteria and update it so that it is marked as 'mine'. How can I do this safely? Given something like this table: create table...
5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
0
by: Steve Crawford | last post by:
In one system I have a table of work to be done (for simplicity in this explanation I'll use a table consisting of id and status). A client-side app needs to fetch 10 available items from the...
3
by: charles | last post by:
I've got maybe a stupid question, concerning the difference between a simple select and a select for update ( otherwise identical ). The plan for such selects - in a DPF enviropnment - are...
29
by: Geoff Jones | last post by:
Hi All I hope you'll forgive me for posting this here (I've also posted to ado site but with no response so far) as I'm urgently after a solution. Can anybody help me? I'm updating a table on...
4
by: Nick Barr | last post by:
Hi, I am trying to gather stats about how many times a resource in our web app is viewed, i.e. just a COUNT. There are potentially millions of resources within the system. I thought of two...
4
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement...
5
by: rAinDeEr | last post by:
Hi, I have a web application with a table to store terms and conditions of a Company. This may some times run into many pages and some times it may be just a few sentences. It is a character...
5
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.