To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Miscellaneous > General Database Discussions

General Database Discussions Discuss any database topic not covered in any other forum on this site

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 10-18-2002, 11:09 PM
Varasano Varasano is offline
Junior Member
 
Join Date: Oct 2002
Location: Atlanta, GA
Posts: 1
Angry SQL Row Level Record Locking

Despite the protestations in the manuals, I need
to lock a row during user input. Obviously, I need to maintain read/write
access to other rows. I thought this would be a straightforward use of
ROWLOCK, but I am having problems.


DECLARE LockTest CURSOR
GLOBAL SCROLL DYNAMIC SCROLL_LOCKS TYPE_WARNING FOR
SELECT * FROM TestTable WITH (ROWLOCK)
WHERE UID = @MyUID
FOR UPDATE

OPEN GLOBAL LockTest
FETCH FIRST from LockTest

Note the following:
1- UID is an Indentity Column. If I use UID or any numeric column in the
where clause (whether indexed or not indexed), this cursor seems to
block the formation of any other FOR UPDATE cursor on this table,
even for different values of @MyUID. However, if I use a varchar
column everything works as expected.
WHERE Code = @MyStringCode

Using the varchar column, I time-out if two connections use the same
@MyStringCode, but can create multiple cursors if @MyStringCode is unique.

Obviously, I want to use my identity column virtually 100% of the time
for this type of operation, not a varchar column.

2- SP_LOCKS returns the exact same entries for both varchar and int
WHERE clauses


3- I thought that KEYSET was a better choice than DYNAMIC. However
I get a runtime error:
"FOR UPDATE Cannot be specified with a READ ONLY cursor"
Removing the FOR UPDATE clause, causes me to get
"The cursor is READ ONLY"
despite the fact that I declared it SCROLL_LOCKS
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:32 AM.


DatabaseJournal Recent Articles


 » Grouping with SQL Server 2008

 » Conducting Service Broker Conversation Usi...

 » Applying data warehousing principles to ev...

 » Oracle New Year's resolutions, part 1: Adv...

 » Hands on: Understanding SQL queries

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.