Fake update or select with (udplock) or select with (updlock, rowlock)?

I need  to block some rows to control the concurrency. I have this table:
Table(ID, Concurrency...)
Concurrency is a nullable bit that is only used to do the fake update.
I need to block the row to avoid that the row is selected by a second process one the first select it. So by the moment I am doing:
begin tran
Update Table set Concurrency = Concurrency where ID = 123
--My process
commit
In this case, when two process execute the same code, the first one block the row with ID 123 and the second process has to wait until the first process ends.
I am trying to use hints for this, to avoid the need of the fake update, because I guess that has worst performance than a select, so I have tried something like that:
begin tran
select * from Table with(rowlock, xlock) where ID = 123
commit
With serializable isolation level too, that is the most restrictive, but sometimes, with some conditions in the where, the row is not blocked. So that is the reason why I am using the fake update, because the update works always.
However, I have read that I can use the hint UPDLOCK, that seems that locks the row in the select, but how it is a hint, I am not sure if this solution block always the row or sometimes doesn't do it, like the rowlock, xlock. I have tested this and it seems
that works, but when I use an ID as condition, I don't know if it works in all cases.
Another alternative that I have seen is with (UPDLOCK, ROWLOCK). What is the difference? Because with only UPDLOCK only locks the rows affected by the conditions in the where, so I am not sure why to use ROWLOCK too.
What I want is to ensure that I block the row until the process has finished.
There are any other alternative to block a row to avoid the select?
Thank so much.

First of all, have you looked at application locks? Maybe this is what's need rather than fake updates?
UPDLOCK is a hint on the same parity as XLOCK. XLOCK takes out an exclusive lock, and no other process can access the row. But some the engine dodges the lock it seems.
UPDLOCK does not prevent other process from reading the row with a regular shared lock. However, only one process at a time can have an Update lock on a row. The purpose for an UPDLOCK is to mark that you intended to update the row later.
ROWLOCK controls the granuality, and since row lock is the default lock granularity it should not be needed in very many cases.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • I selected update option and it erased my ipod with all downloaded and paid materials...any ideas for how to restore?

    I selected the update option and it erased my ipod with all downloads and other materials lost...any ideas on how to restore?

    Everything should be on your computer.  Just sync it back.
    Did you fail to make sure that everything was on your computer before updating?

  • My keyboard is locked with a message that says, "carrier settings update available" but I can't select either option.....please advise

    My keyboard is locked with an update message and I can't select either option....how can I get going again?

    1. Hold the Sleep and Home button down together
    2. For about 10 seconds
    3. Until you see the Apple logo
    4. Ignore the red slider

  • TS1702 Has anyone had any issues with the app scramble with friends after updating to iOS 6. The touch screen is not responding properly when selecting the tiles but worked fine before the update

    Has anyone had an issue with the app scramble with friends after upgrading to iOS 6. Tapping the screen will not select the tiles and hold them.

    Yes I am having the same problem. I can't find any info about it and nothing seems to help. I am just posting this in hope that if it's a wider problem, there will be a quick solution.

  • I was getting messages that my Aperture Library was full, so I updated to Aperture 5.3.1. When I open it, I'm asked to update my library. When I select that option, I'm told that my library is full. Now I can't access my library at all. What should I do t

    Hi all,
    I was getting messages that my Aperture Library was full, so made an appointment at my closest Mac store, but have to wait 2 days. They advise you to update saoftware before coming in, so I updated to Aperture 5.3.1. When I open it, I'm asked to update my library. When I select that option, I'm told that my library is full. Now I can't access my library at all. What should I do to access my library? Do I have to uninstall 5.3.1 and reinstall an older version?
    Another problem I have recently encountered ... all the up and down scrollers on various screens have disappeared. They reappear fleetingly when I use my up and down arrowa, but I can't always catch them. How do I get my scrollers back?

    Thank you so much for your patient guidance and screen captures.
    You are welcome.
    My external hard drive is properly formatted for Aperture, so I am currently copying my Aperture library to it. That will take hours since it is copying 101 GB.
    o.k.
    I understand that I need to clean some space on my internal hard drive and reformat the Aperture library to get back in operation.
    You need to upgrade the Aperture library to be used with Aperture 3.5.1.  That will happen automatically, when you first double click the copied lirary to open it in Aperture.
    I'll also need to back up my external drive with a new external drive if I make space on my internal drive by removing some photos from there and store them on my current external drive.
    What do you use for backup? If you are using TimeMachine it is better to have only the Time Machine backup on the Time Machine drive . In that case would I put the Aperture library and other data on a new drive and keep the old drive for backup.

  • Impossible make a selection in Photoshop CC 2014 with 4GB of RAM

    Well I know that I need update my system to 64bit, but year ago was possible work and make selection with Photoshop CC, now is impossible with Photoshop CC 2014 with 4gb of RAM

    CC 2014 has twice the ram requirements of CC. While 2 GB is minimum, 8 GB is recommended.
    You will have to upgrade your system or go back to CC.
    System requirements | Photoshop
    Gene

  • Error in select list w/submit proccessing with IE

    I have encountered a problem that is only IE specific. The page is a basic page with an Automated Row Processing to insert the form to a table.
    Once the form has been filled out and you press create there are seven total fields including a hidden field (p173_model_id) that is populated by a database trigger and sequence. All of the fields in essence save to session state to the field following that field. So for instance the vendor_id saves to the model_number field. The model_number field saves to the status field and so on! This only occurs with IE though not with FF. In FF everything works as planned.
    Also if you change the container Type field from select list with submit to just select list the form handles fine now in IE.
    Attached are pictures trying both IE and FF:
    FF
    IE
    You can view the backend @
    workspace:epic
    guest/guest
    http://apex.oracle.com/pls/otn/f?p=9579:173
    Thanks
    Justin

    Here is an update in case anyone else experiences the problems I had...
    The SR request I filed was given bug # 5716829 I am not sure if this is published or not....
    Anyway here is what the development staff reported back:
    I have narrowed this problem down to the Read Only Condition on the P173_CONTAINER_TYPE_ID select list.
    If you remove "DISABLED" from the Read Only Element Table Cell(s) Attributes, it works fine in IE also. So, the problem seems to be
    with the way IE handles Select Lists that are DISABLED.
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    You may use that as a workaround until the fix is available...

  • Problems with PreparedStatement when select restrict are byte params

    Hi,
    i have a problem trying to select information when the "select" has a byte restrict.
    The table in database is:
    CREATE TABLE `positions` (
    `PKID` int(10) unsigned NOT NULL auto_increment,
    `POSCODE` varbinary(30) NOT NULL,
    `ISWTURN` binary(1) NOT NULL,
    `QTT_GAMES` int(10) unsigned NOT NULL default '1',
    PRIMARY KEY (`PKID`),
    UNIQUE KEY `UNIQ_POS` (`POSCODE`,`ISWTURN`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    And the test code to get the qtt_games is :
    conn = DriverManager.getConnection (url,user,pwd);
    byte bcode[] = poscode.getByteArrayCode();
    // bcode is inserted ok in another preparedstatement...
    String query = "SELECT qtt_games FROM positions "+
    "WHERE poscode=? and iswturn=?";
    PreparedStatement pstmt = conn.prepareStatement(query);
    pstmt.setBytes (1,bcode);
    pstmt.setByte (2,poscode.getIsWhiteTurn()); //it returns a byte
    ResultSet rs = pstmt.executeQuery (query);
    When pstmt.executeQuery is reached, it's thrown the exception:
    com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=? and iswturn=?' at line 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3170)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
    at com.mysql.jdbc.Statement.execute(Statement.java:695)
    at app.server.bbdd.MYSQLBDManager.getGamesBasicInfo(MYSQLBDManager.java:942)
    at app.server.bbdd.MYSQLBDManager.main(MYSQLBDManager.java:1068)
    Can anybody tell me what's wrong?? I think the query is ok, but don't know what's happening with this...
    Lots of thanks.

    Hi,
    sorry, i know i've post this same message by error in "new to java" thread.... (i'm new in the forum... can i delete the wrong comment??)
    The SQLState is 42000 (syntax error), but it doesn't give me much information because i had already searched in google why can be the cause of it, but there are only a few comments about problems like this, without a solution...
    The column poscode in the table positions contains an array of bytes that codify a position in a chess board. I've to use this in the WHERE clause because i'm developing a chess game consulting project where there are millions of different positions and i've to get the games that have the same position in it's position history.
    The code to insert the positions is:
    query = "INSERT INTO positions VALUES "+
         "(null,?,?,default) "+
         "ON DUPLICATE KEY UPDATE qtt_games=qtt_games+1";
    pstmt = conn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
    pstmt.setBytes(1,bcode);
    pstmt.setByte(2,poscode.getIsWhiteTurn());
    pstmt.executeUpdate();
    which works ok and positions can be seen from mysql browser, but i can't select them using the PreparedStatement..
    I have been searching a lot of information about this problem with no results... this is the why i posted this...
    Any help will be useful, thanks.

  • Peculiar problem in LDB ADA with company code selection

    <h5>Hello Colleagues, </h5>
    Faced a peculiar problem with company code selections in LDB ADA. Entered depreciation area, dep posting perios, lower and higher value of company code and would like to except few companies from selections. On pressing extension button, error message "Depreciation area 01 is not defined in chart of depreciation" is popping up and not allowing to provide exceptions for company codes. But working well in development systems. We are using ECC 6.0 systems and in both systems we have same lines of code for SAPDBADA.
    During debug, found that in development system, control coming to initial statements after PAI event. But in other systems, control skips few initial commands after PAI and directly jumps to later commands. Due to this FNAME parameter in PAI subroutine setting with '*' in other systems and 'BUKRS' in dev system.
    Could anybody give me some thoughts of why system behaving differently?
    Thanks and Regards,
    Prasanth

    Some - or most? - ODBC driver, especially MS for SQLServer and Access, don't support these advanced JDBC features.
    Like the messages says: they are optional features, and the driver doesn't implement them.
    A good news:
    you don't need them.
    Just go through your ResultSets only forward by next(), and do all inserts, updates and deletes with executeUpdate() and SQL commands.

  • IPhoto 08 vsn 7.1.5 software issue.  Can't print a photo.  When I select print it comes up with the error message "No available themes" There were no themes located. Until at least one theme has been installed, this feature will be unavailable. ugh

    Can't print a photo.  When I select print it comes up with the error message "No available themes" There were no themes located. Until at least one theme has been installed, this feature will be unavailable. ugh.  Uploaded latest update but it still doesn't work.  Was going to try and load the software again but can't find the source as a download. 
    Cheers,
    Papasailor

    YOu need to reinstall iPhoto.
    To re-install iPhoto
    1. Put the iPhoto.app in the trash (Drag it from your Applications Folder to the trash)
    2a: On 10.5:  Go to HD/Library/Receipts and remove any pkg file there with iPhoto in the name.
    2b: On 10.6: Those receipts may be found as follows:  In the Finder use the Go menu and select Go To Folder. In the resulting window type
    /var/db/receipts/
    2c: on 10.7 or later they're at
    /private/var/db/receipts
    A Finder Window will open at that location and you can remove the iPhoto pkg files.
    3. Re-install.
    If you purchased an iLife Disk, then iPhoto is on it.
    If iPhoto was installed on your Mac when you go it then it’s on the System Restore disks that came with your Mac. Insert the first one and opt to ‘Install Bundled Applications Only.
    If you purchased it on the App Store or have a Recent Mac you can find it in your Purchases List.

  • Error  " Selected numbers does not agree with transferred"

    Hi,
    While in production support I got a issue saying
    Error  " Selected numbers does not agree with transferred"
    How to solve this.
    Regards
    San Reddy

    Hi,
    This doesnt mean that its a failure.
    I will suggest you to check a few places where you can see the status
    1) SM37 job log (In source system if load is from R/3 or in BW if its a datamart load) (give request name) and it should give you the details about the request. If its active make sure that the job log is getting updated at frequent intervals.
    Also see if there is any 'sysfail' for any datapacket in SM37.
    2) SM66 get the job details (server name PID etc from SM37) and see in SM66 if the job is running or not. (In source system if load is from R/3 or in BW if its a datamart load). See if its accessing/updating some tables or is not doing anything at all.
    3) RSMO see what is available in details tab. It may be in update rules.
    4) ST22 check if any short dump has occured.(In source system if load is from R/3 or in BW if its a datamart load)
    5) SM58 and BD87 for pending tRFCs.
    Once you identify you can rectify the error.
    If all the records are in PSA you can pull it from the PSA to target. Else you may have to pull it again from source infoprovider.
    If its running and if you are able to see it active in SM66 you can wait for some time to let it finish. You can also try SM50 / SM51 to see what is happening in the system level like reading/inserting tables etc.
    If you feel its active and running you can verify by checking if the number of records has increased in the data tables.
    SM21 - Job log can also be helpful.
    In your case its probably because of tRFC issue.
    Check SM58 / BD87 for pending tRFCs.
    Thanks,
    JituK

  • How do I constrain anchor angle when I tug on a path with the direct select tool?

    How do I constrain anchor angle when I tug on a path with the direct select tool like it did in every version of Illustrator since 1988? New behavior is costing me time.

    That solves it!
    I was not able to find this in the online materials about the pen tool.  In fact, Illustrator Help | Adjust path segments does not show the new functionality at all.  They need to update that article.
    Better way to implement the new functionality
    It would have been nice if Adobe added to the chording controls for the direct select tool the ability to toggle this setting temporarily by holding down the space bar after mouse down to drag a segment.
    Before mouse down this would give the user the hand tool.
    If, after mouse down, I could hold space bar and have the behavior switch from the historical capability where dragging a segment cannot change adjacent segments to the new behavior where dragging the segment cannot move anchors but can rotate them, I am sure I would find times when the tool saved time. If, before mouse up, I release spacebar, turn the constraint back on with anchors pointing in their new directions and allow me to stretch the curve protecting the new shapes of adjacent curves.
    Using space bar for this would be intuitive to me because holding down the space bar is something I already do to organically drag the page around with the hand tool. The new tool allows me to more organically stretch artwork around, something that is distantly analogous, but close enough to remember.
    For long time Illustrator users, the chording features holding Ctrl/Alt/Shift/Space or Ctrl/Command/Shift/Space in different combinations while using the direct select tool and pen tool is the killer app part of Illustrator that keeps us using it. This what we did on Illustrator 88 on a Mac Plus in 1988 and is still the most productive way to produce vector art when precision is required.

  • J1INUT Error - No data exist for processing with the given selection option

    Hi Guru's,
    I am using transaction J1INUT utilization of provision of TDS on Services for which in have made the provision with the help of J1INPR, But when I am executing J1INUT transaction .The following error message is displaying:
    No data exist for processing with the given selection options
    I have followed the below steps.
    1) ME21N - OP Creation
    2) ML81N - Service Entry
    3) J1INPR - Provision of TDS
    4) MIRO -  Invoice Posting
    I have checked the Table J_1IEWTPROV In that system is updating the table also. Even I have activated table TRWCA for field IND
    But still I am getting the same error. Any suggestions to resolve this.
    Appreciate your inputs. Thanks in Advance
    Regards,
    DeepaK

    Hi Deepak,
    Refer the below link and follow the steps - Provision for Taxes on Service Recieved.
    Re: Provision for Taxes on Service Recieved
    Hope it may useful to you.
    Regards,
    Govind Bhaskaran

  • Hi, I tried to create a slideshow that contain more than 500 photos. Now, trying to open / execute / select the slideshow, iPhoto hangs with the spinning coloured wheel and I have only to force the deletion from System Preference. Any suggestion?

    Hi, I tried to create a slideshow that contain more than 500 photos. Now, trying to open / execute / select the slideshow, iPhoto hangs with the spinning coloured wheel and I have only to force the deletion from System Preference. I already tried to rebuild the iPhoto Library (all the possible options) and tried to update teh version from 9.4.3 to 9.5 but the problem still persists: is there a way to delete this slideshow without selecting it ? How can I solve the problem, please?
    Kind Regards

    Can you restore your iPhoto Library from a backup version, that was created before you added the slideshow?
    If not, have you tried to rebuild the slideshow with iPhoto Library Manager?
    As described by Terence Devlin here:  Re: iphoto library was created with an unrelased version of iphoto please quit and ugrade library by opening it in iphoto 2 or iphoto 4

  • I updated Firefox and now, when I select File, Send Link, a dialog box pops up asking me to establish a new account before I can send the link via email.

    I updated Firefox and now, when I select File, Send Link, a dialog box pops up asking me to establish a new account before I can send the link via email. I use Outlook, so how do I avoid setting up some new account and yet am able to send the link via Outlook?
    I have a feeling it may have something to do with HotMail.com.

    My Error: I found out that it was Mozilla Thunderbird that was causing the problem. I uninstalled it and the problem went away.

Maybe you are looking for