Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Perl Query Locks A MsSQL Database

by nikosv (Chaplain)
on Jan 23, 2013 at 20:24 UTC ( #1015016=note: print w/replies, xml ) Need Help??

in reply to Perl Query Locks A MsSQL Database

use SQL server's profiler to check for blocking locks.My guess is that the first cursor still has a shared lock on the rows read and while not yet completed you open another cursor (update) which conflicts with the previous one.

What is your isolation level? try setting the isolation level for the session to READ UNCOMITTED just to check that it's a locking issue;remember this isolation level is not otherwise recommended

you are using cursor-based procedural logic;try to mix your select with the update in one query and since I see that you check the values of 2 returned columns,use a CASE clause to place your filter and do your update

or read all rows in an array,commit the select and then iterate through it in the client's memory,opening a cursor and doing your updates. However this has the drawback that your update might fail if another transaction has already changed your row in the mean time,since you take no shared/read locks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015016]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2018-06-23 03:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.