How to lock the rows in a transaction so others cant modify the rows

Hi,
I want few suggestion in the following scenario .
I have a few records ( say 100 ) in a table which Im sending to the client over a network and are populated in a swing GUI...Now the client selects few of them ( say 3 ) and submits to the server. Now the server should assign a number to those rows and store them in the database. As it is a multi client environment While assigning the number it should check that no other client has already assigned a number to at lease to one of the row in the meantime. in that case it shoudl fail.
In this case i want to lock those 3 records when the request arrives at the server assign number commit and release the lock.
I want to avoid deadlocks.
Can any one suggest me whoch locking policy should i use and how ?
Thanx in advance...
Mahi

It depends on how acceptable it is for your commit to fail. By far the easiest and safest thing to do is use Optimistic Locking. This way if the server tries to commit changes to something that has already been committed, an Optmistic Lock exception will be thrown. It's up to your application to handle this, and depending on your domain and the likelyhood of this happeneing, you could just tell the user "try again". The other option is pessemistic locking, which is very, very, dangerous (in my opinion). The main issue is that it's resource intensive, and different databases have different semantics on how it works.
IIWY, I'd look at Optimistic Locking in the docs and go from there.
- Don

Similar Messages

  • How to lock the rows in program

    how to lock the rows in program

    Do not create a duplicate thread.
    many had already answered your query here.
    how to lock the rows in program
    Regards,
    Prazy

  • How to lock a row in a db2/400

    Hi all,
    Could someone show me how to lock a row in the database DB2/400
    The scenario:
    DB.beginTransaction
    User 1 gets a row with a column bill_number
    "select bill_number from numbers where pk = xxx for update"
    aux_bill_number = bill_number
    USER 1 updated this row
    "update numbers set bill_number = bill_number +1 where pk = xxx "
    USER 1, like final step, insert aux_bill_number in other table as primary key
    DB.commitTransaction
    While doing so,
    User 2 also gets a row with a bill_number. this user must take bill_number with value 2, but take the same value 1
    This it causes key duplicated in the destiny table.
    Please, help me.
    How I must lock the row not to allow to read until finishing the previous transaction?

    Hi all,
    Could someone show me how to lock a row in the
    database DB2/400Isn't SELECT FOR UPDATE standard?
    >
    The scenario:
    DB.beginTransaction
    er 1 gets a row with a column bill_number
    "select bill_number from numbers where pk =
    xxx for update"
    aux_bill_number = bill_number
    1 updated this row
    "update numbers set bill_number = bill_number
    +1 where pk = xxx "
    USER 1, like final step, insert aux_bill_number in
    other table as primary key
    DB.commitTransactionSounds like you're trying to do something that a JOIN would do better.
    While doing so,
    User 2 also gets a row with a bill_number. this user
    must take bill_number with value 2, but take the
    same value 1
    This it causes key duplicated in the destiny table.
    Please, help me.
    How I must lock the row not to allow to read until
    finishing the previous transaction?Setting the isolation level to SERIALIZABLE might help.
    %

  • How to lock a row in a db

    Hi,
    Could someone share the code for how to lock the whole database, part of the database or just a row in the database?
    Thanks.

    Whoops... I am sorry about that.
    I am asking about MS Access (version 2002 if that matters)
    Thanks,
    Yaakov.

  • How to lock a row by using 'for update'?

    how to lock a row by using 'for update'?

    Hi,
    SELECT * FROM <TABLE> WHERE <PK_COLUMN>=<VALUE> FOR UPDATE NOWAITThis will help in locking the row with the primary key value that you provide
    cheers
    VT

  • How to Lock the master data. R/3 Conflict ESS

    Dear Gurus,
    Please guide me how to lock the master data for a nos of days(say 7 days).
    Recently we had encountered an issue, related to ESS. While Uploading the Time data through t-code: PT60, our core team encountered a problem, that such and such employee number is locked.
    While checking, they identified it, system shown error against those employees, who are accessing their ESS. We check and came to know they are accessing the master data by changing their personal record i.e. address.
    Do we have any other provision to lock the master data without setting the control record to release for payroll.
    Please help .

    Create a custom transaction involving a custom views of table T7XSSSERSRV  with the following field for each service
    "V_T7XSSSERSRV-ISDISABLED"
    when HR wants to lock it, the will enter this table and check this field.
    this will disable the servcies in the front end.
    Once the 7 days are over, HR will uncheck this field. this will re-enable the services in the froint end.
    Hope this helps.

  • How to lock the Printer of LaserJet Pro 500 Color MFP m570dw

    how to lock the Printer of LaserJet Pro 500 Color MFP m570dw

    You can set a control panel lock security level and password for your HP LaserJet series printer. To lock your printer, follow below link:
    http://h20564.www2.hp.com/hpsc/doc/public/display?​docId=emr_na-bpl03612

  • How to make like Encarta encyclopedia and basic screen settings and how to lock the documents in the entire data.

    dear guys how can i make like a off line Encarta encyclopedia and basic screen settings and how to lock the documents in the entire data in visual studio.                 
       thank you. 
                                                              Million
    Getu

    Dave,
    I will +1 Pixelan's products. They are great, simple, and have about the best support that I know of. When you explore, say Pixelan's SpiceMaster, dig deeply. Things appear rather mundane, on the surface, but there is so very much power lurking, just below the surface. I could almost imagine a 1000 page manual to cover every possible aspect of that program... Every time that I use it, I learn something new, and wonderful.
    Good luck,
    Hunt

  • HT4085 how to lock the tauch screen with some password or dots like android to prevent misuse. And also screen lock to prevent interruption while watching movie reading books etc.

    how to lock the tauch screen with some password or dots like android to prevent misuse. And also screen lock to prevent interruption while watching movie reading books etc.

    You can set a passcode to be requied to unlock the iPad via Settings > General > Passcode Lock. In terms of locking the actual screen whilst using an app, then that isn't currently possible, but with iOS 6 in the Autumn there will be a new 'accessibility' feature (from here) which will allow you :
    ... to limit an iOS device to one app by disabling the Home button, as well as restrict touch input on certain areas of the screen

  • How to lock the Properties bar to a toolbar or in some other way, make it permanently open?

    How to lock the Properties bar to a toolbar or in some other way, make it permanently open?
    Or can that checkbox 'keep tool selected' be made a permanent toolbar item?
    I use the rubber stamp tool several times on multiple pages in certain pdfs and found that if I open the 'properties bar', I can select 'keep tool selected' and stamp away as much as I like without having to choose the stamp tool dropdown menu and select 'custom' each time I stamp. I appreciate the recent update that added a recently stamped stamps area and not having to click 'proceed' each time.

    You can't lock the Properties Bar, but you also don't need to in order to make the Stamp tool remain selected.
    Just right-click it in the Comment menu on the right and select "Keep Tool Selected".

  • How to lock the month in Planning web forms

    Hi all ,
    we r using the web forms in planning for inputting the data .
    we had a problem here.
    ex:
    User is giving the in put for the month Dec..and again in he is changing the data..so how to lock the in web forms month wise.
    thanks in Adv

    Hi Bunny,
    Do you mean to say that , once the user inputs the values for the month of Dec,after that , you dont want the user to change the values of dec which he had provided.
    Is that what your montly locking means?
    Sandeep Reddy Enti
    HCC
    http://hyperionconsultancy.com/

  • How to lock the statistics in column level.

    Hi All, i am using 10.2.0.1.0 version of oracle.
    I have gathered freuency histogram manually on one of my column of a table to provide more information to optimizer for better calculation of cardinality.
    Now i have my weekend job runs for gathering stats on schema level with method_opt as 'For all column size repeat'. But i dont want the stats of above column to be overridden by the stats job. I dont want to lock the statistics of whole table, but i just want to lock the column level stats for this table.
    how the above can be achieved?
    Below is the details.
    Code for manual histogram , i have eliminated many buckets purposely, as there are 194 buckets.
    DECLARE
    m_distcnt NUMBER := 916714;       -- num_distinct (As it is there in dba_tab_columns)
    m_density NUMBER := 0.00000109031397771616;  -- density (As it is there in dba_tab_columns)
    m_nullcnt NUMBER := 0;       -- num_nulls (As it is there in dba_tab_columns)
    m_avgclen NUMBER := 8;       -- avg_col_len (As it is there in dba_tab_columns)
    srec      dbms_stats.statrec;
    n_array   dbms_stats.numarray;
    BEGIN
      srec.epc := 3; -- no of end points
      n_array     := dbms_stats.numarray(3870     ,
                                                 3891     ,
                                                 3945     
      srec.bkvals := dbms_stats.numarray(25000     ,
                                                 55000     ,
                                                 100000     ,
      dbms_stats.prepare_column_values(srec, n_array);
      dbms_stats.set_column_stats('Schema1', 'USERS_HIST_TEST', 'COMPANYPK',
      distcnt => m_distcnt,
      density => m_density,
      nullcnt => m_nullcnt,
      srec    => srec,
      avgclen => m_avgclen,
      force => TRUE);
    END;
    -- Weekend job which will override above histogram
    DBMS_STATS.GATHER_SCHEMA_STATS (
        ownname          => 'Schema1',
        estimate_percent => dbms_stats.auto_sample_size,
        block_sample     => FALSE,
        method_opt       => 'FOR ALL COLUMNS SIZE REPEAT',
        DEGREE           => dbms_stats.default_degree,
        granularity      => 'DEFAULT',
        CASCADE          => TRUE,
        options          => 'GATHER STALE'
    Edited by: 930254 on Jul 4, 2012 9:08 AM

    Pl do not post duplicate threads - How to  lock the statistics in column level.

  • How to lock the perticular record in table with some of fields

    Hi,
    I have one Doubt please clarify me.
    How to lock the record in table with perticular fields combination please give me example of code.
    Thanks,
    Hari.

    Hi,
    IT LIKE this....
    This is the function mode that you have to create for locking the contents of you internal table.
      CALL FUNCTION 'ENQUEUE_EZHFINDID'
       EXPORTING
         mode_zhfindid        = 'E'
         mandt                = sy-mandt
         ownid                = w_display-ownid
      X_OWNID              = ' '
      _SCOPE               = '2'
      _WAIT                = ' '
      _COLLECT             = ' '
       EXCEPTIONS
         foreign_lock         = 1
         system_failure       = 2
         OTHERS               = 3.
      CASE sy-subrc.
        WHEN 1.
          w_flag_lock = c_x.
         CLEAR w_okflag.
          MESSAGE e265 WITH w_display-ownnum.
      ENDCASE.
    Jayant Sahu.

  • How to lock the record in the Form

    .How to lock the record
    That is In my customized form if user query the record in one of our Customized form and the system automatically should prevent by quering the same record by other user for the same form .The message to be displayed as locked by another user .
    For example in standard form the same option is available.
    Form Name:GMEBCHED.FMB
    Module:ORACLE PROCESS MANUFACTURING(OPM)
    Could you pls help us how to implement the same for our Customized form .
    Appricaiate your help .
    Regards,
    Radha krishnan

    Hi,
    I tried to put the code under Post-Query trigger. Since user can input the selection criteria in the form. After the form open, after I input the "Update user" ID (this is in the non-base table block), the oracle message prompt: FRM-40653: Record not reserved for update or delete. Try again later..
    So, is there any method to solve it?
    Thanks a lot.
    Regards.

  • How to lock a row and release lock

    Hello
    There are two thread, they read the same row, I want to lock this row when the first thread read the record, after this thread commit its data, release the lock, the second thread can lock this record, also can commit its data. I also want to know how to release the lock. And these operations are in different Classes, e.g. in Class A first thread lock the record, in Class B second lock the record, and in Class C release the lock.
    Note: these two thread will read this record at same time.
    Thanks in advance.

    TopLink provides to forms of locking, optimistic and pessimistic.
    <p>
    You are referring to pessimistic. You can use pessimistic locking in TopLink through the ReadObject/ReadAllQuery API acquireLocks(), or acquireLocksWithoutWaiting(), this will use a "Select ... for Update" in SQL. You must be in a transaction to lock a row in the database (UnitOfWork in TopLink), and you locks are released when you commit or rollback the transaction. If you are using JPA, TopLink supports a JPA query hint "toplink.pessimistic-lock"="Lock" to allow pessimistic locking.
    <p>
    You can also use optimistic locking. An optimistic lock does not prevent another user from reading the same row, but ensures that only one user will be able to commit changes to the row. Optimistic locking typically has the advantage of better concurrency, and does not have issues with deadlocks.
    <p>---
    <br>James Sutherland
    <br>Oracle TopLink, EclipseLink
    <br>Wiki: Java Persistence, EclipseLink

Maybe you are looking for

  • Can you please help me create this graph?

    I have spent over 10 hours trying to create something similar to this graph in Numbers and Pages. Pages and Numbers forces me to use automated Min and Max axes in order to display evenly distributed numbers. Because of the wide difference between num

  • In iPhoto, one upload of photos does not appear in events

    I recently uploaded ~30 photos to iphoto from a Canon SD750.  The photos appear in photo mode, and are split into an event in photo mode (I even named the event in photo mode), but do not appear as an event in Event mode.  Just previously, I uploaded

  • Can't create an ePrint account

    i can't create an eprint account with my Laserjet Pro 200 m251nw.  When I go to create an account, it showsthat both the email and passworddo not match.  I am operating Windows 7 Home Premium.   I have tried both my personal e-mail and the printer e-

  • Partition InfoCubes for non-cumulatives

    Hi, I would like to partition inventory cube 0IC_C03 that consists of non-cummulatives. The partition was executed from 12.2007 to 12.2010. I would like to add partition to 12.2012 via option "Adding Partitions". There was error prompt that infocube

  • How to find bounds of textcolumn

    Hello , can anybody tell me ,how to find bounds of textcolumn.