 |
|
 |
|
Next: Profiler and XML templates: How do I see the para..
|
| Author |
Message |
External

Since: Jan 15, 2007 Posts: 6
|
(Msg. 1) Posted: Fri Oct 27, 2006 11:52 am
Post subject: Need a deadly row lock through oledb Archived from groups: microsoft>public>data>oledb, others (more info?)
|
|
|
Hi,
I might have asked this before, but since SQL 2005 was there, MS strongly
modified locking in favor of scalability.
I never got an answer that solved the problem.
I have an app that really needs to lock a certain row to be locked so that
other apps in the network, get into a wait queue, until the row gets
released. On SQL 2000 this worked.
Some facts,
1) It is C++, no dotnet is -going- to be used ever in this app.
2) The point is not scalability but functionality here.
The required properties which worked in SQL 2000 were
propset.AddProperty(DBPROP_IRowsetChange, true);
propset.AddProperty(DBPROP_OTHERUPDATEDELETE, true);
propset.AddProperty(DBPROP_OWNUPDATEDELETE, true);
propset.AddProperty(DBPROP_UPDATABILITY, (LONG) DBPROPVAL_UP_CHANGE);
propset.AddProperty(DBPROP_SERVERCURSOR, true);
propset.AddProperty(DBPROP_LOCKMODE, (LONG)DBPROPVAL_LM_SINGLEROW); >> Stay informed about: Need a deadly row lock through oledb |
|
| Back to top |
|
 |  |
External

Since: Oct 24, 2006 Posts: 87
|
(Msg. 2) Posted: Fri Oct 27, 2006 11:52 am
Post subject: Re: Need a deadly row lock through oledb [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I'm not aware of the property-setting approach you're currently using,
but the standard way to lock a row is to use a locking hint within a
transaction.
e.g.
BEGIN TRANSACTION
SELECT * FROM YourTable WITH(XLOCK) WHERE YourID = @ID
This keeps the row locked until you issue a COMMIT TRANSACTION.
Egbert Nierop (MVP for IIS) wrote:
> Hi,
>
> I might have asked this before, but since SQL 2005 was there, MS strongly
> modified locking in favor of scalability.
> I never got an answer that solved the problem.
>
> I have an app that really needs to lock a certain row to be locked so that
> other apps in the network, get into a wait queue, until the row gets
> released. On SQL 2000 this worked.
>
> Some facts,
> 1) It is C++, no dotnet is -going- to be used ever in this app.
> 2) The point is not scalability but functionality here.
>
>
> The required properties which worked in SQL 2000 were
>
> propset.AddProperty(DBPROP_IRowsetChange, true);
> propset.AddProperty(DBPROP_OTHERUPDATEDELETE, true);
> propset.AddProperty(DBPROP_OWNUPDATEDELETE, true);
> propset.AddProperty(DBPROP_UPDATABILITY, (LONG) DBPROPVAL_UP_CHANGE);
> propset.AddProperty(DBPROP_SERVERCURSOR, true);
> propset.AddProperty(DBPROP_LOCKMODE, (LONG)DBPROPVAL_LM_SINGLEROW); >> Stay informed about: Need a deadly row lock through oledb |
|
| Back to top |
|
 |  |
External

Since: Jan 29, 2004 Posts: 1559
|
(Msg. 3) Posted: Fri Oct 27, 2006 1:40 pm
Post subject: Re: Need a deadly row lock through oledb [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
> SELECT * FROM YourTable WITH(XLOCK) WHERE YourID = @ID
Be aware. The XLOCK hint is very dangerous. There's an optimization for exclusive row locks, making
the hint useless or even dangerous in some cases. If memory serves me, the lock can be ignored by
regular reads if the row wasn't modified since the earlier open transaction. This is easy to test
and verify (that a subsequent read will read the row even though the lock is there).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Chris Lim" wrote in message
> I'm not aware of the property-setting approach you're currently using,
> but the standard way to lock a row is to use a locking hint within a
> transaction.
>
> e.g.
>
> BEGIN TRANSACTION
>
> SELECT * FROM YourTable WITH(XLOCK) WHERE YourID = @ID
>
> This keeps the row locked until you issue a COMMIT TRANSACTION.
>
> Egbert Nierop (MVP for IIS) wrote:
>> Hi,
>>
>> I might have asked this before, but since SQL 2005 was there, MS strongly
>> modified locking in favor of scalability.
>> I never got an answer that solved the problem.
>>
>> I have an app that really needs to lock a certain row to be locked so that
>> other apps in the network, get into a wait queue, until the row gets
>> released. On SQL 2000 this worked.
>>
>> Some facts,
>> 1) It is C++, no dotnet is -going- to be used ever in this app.
>> 2) The point is not scalability but functionality here.
>>
>>
>> The required properties which worked in SQL 2000 were
>>
>> propset.AddProperty(DBPROP_IRowsetChange, true);
>> propset.AddProperty(DBPROP_OTHERUPDATEDELETE, true);
>> propset.AddProperty(DBPROP_OWNUPDATEDELETE, true);
>> propset.AddProperty(DBPROP_UPDATABILITY, (LONG) DBPROPVAL_UP_CHANGE);
>> propset.AddProperty(DBPROP_SERVERCURSOR, true);
>> propset.AddProperty(DBPROP_LOCKMODE, (LONG)DBPROPVAL_LM_SINGLEROW);
> >> Stay informed about: Need a deadly row lock through oledb |
|
| Back to top |
|
 |  |
External

Since: Jan 15, 2007 Posts: 6
|
(Msg. 4) Posted: Fri Oct 27, 2006 1:52 pm
Post subject: Re: Need a deadly row lock through oledb [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Chris Lim" wrote in message
> I'm not aware of the property-setting approach you're currently using,
> but the standard way to lock a row is to use a locking hint within a
> transaction.
>
> e.g.
>
> BEGIN TRANSACTION
>
> SELECT * FROM YourTable WITH(XLOCK) WHERE YourID = @ID
>
> This keeps the row locked until you issue a COMMIT TRANSACTION.
Even without transactions, a server-side cursor, opened with a pessimistic
row lock worked.
Note it is a serverside cursor.
The code that you have shown, is common TSQL which I cannot use here.
Thanks anyway. >> Stay informed about: Need a deadly row lock through oledb |
|
| Back to top |
|
 |  |
External

Since: May 30, 2004 Posts: 2061
|
(Msg. 5) Posted: Fri Oct 27, 2006 2:16 pm
Post subject: Re: Need a deadly row lock through oledb [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Egbert Nierop (MVP for IIS) (egbert_nierop@nospam.invalid) writes:
> I might have asked this before, but since SQL 2005 was there, MS strongly
> modified locking in favor of scalability.
> I never got an answer that solved the problem.
>
> I have an app that really needs to lock a certain row to be locked so that
> other apps in the network, get into a wait queue, until the row gets
> released. On SQL 2000 this worked.
>
> Some facts,
> 1) It is C++, no dotnet is -going- to be used ever in this app.
> 2) The point is not scalability but functionality here.
>
>
> The required properties which worked in SQL 2000 were
>
> propset.AddProperty(DBPROP_IRowsetChange, true);
> propset.AddProperty(DBPROP_OTHERUPDATEDELETE, true);
> propset.AddProperty(DBPROP_OWNUPDATEDELETE, true);
> propset.AddProperty(DBPROP_UPDATABILITY, (LONG) DBPROPVAL_UP_CHANGE);
> propset.AddProperty(DBPROP_SERVERCURSOR, true);
> propset.AddProperty(DBPROP_LOCKMODE, (LONG)DBPROPVAL_LM_SINGLEROW);
It would be interesting to know what you really want to achieve. Using
SQL Server's row locks for internal application logic is a risky game.
And it does not help if you insist on not using SQL, but rely on what
the OLE DB provider produces. Now there is one more player that may
do things you don't expect it to. While it may have worked on SQL 2000,
it may be an uphill battle to get it to work on SQL 2005. The place
to start look would be to run a Profiler trace to see when the OLE DB
provider emits.
The alternatives that comes to mind is to use application locks. And,
if the purpose is to implement a queue of some sort, you should
definitely look into Service Broker.
--
Erland Sommarskog, SQL Server MVP, esquel DeleteThis @sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx >> Stay informed about: Need a deadly row lock through oledb |
|
| Back to top |
|
 |  |
| Related Topics: | problem using oledb + informix - Hi all. I have a problem writing a table on informix (IDS 10.0) using a linked server on SqlServer Express: This is the insert: INSERT INTO unixdb1.practor.informix.ven_rilcld (rilcld_rilcld,rilcld_entazi, rilcld_numter, rilcld_codbar, rilcld_qta, ..
openrowset and jet.oledb - Please help, since the introduction of SQL2005 the default mode for opening access mdb databases with Openrowset appears to be in exclusive open mode I wish to open the database in share mode so the other (non net) ADO threads can open the database at....
Microsoft.Jet.OLEDB.4.0 - Error - Hi, I am using SQL Server 2005 (SP1) on Windows Server 2003 EE (SP1). I get following error while accessing Excel or Text file data sources with OPENROWSET or OpenDataSource and Microsoft.Jet.OLEDB.4.0: From SQLAgent Job Log file: Cannot initialize....
intermittant OLEDB query failure - I have the following query that I'm using to update pricing from a spreadsheet to a MS SQL(1005) DB Table as we prepare to move to a new quoting system. UPDATE DT SET [BasePrice] = ST.RawPrice ,[BaseCost] = ST.RawCost from..
Launching oracle jobs from oledb - perhaps the wrong group, but I suspect somebody here has tried it... Greetings. I have a vb.net oledb procedure that can schedules an oracle procedure to run and returns to me an oracle job number. It looks like this: FUNCTION CPM_SUBMIT (iprocname i... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|