Optimistic locking/ data concurrency and consistency

Hi,
When creating a tabular form using wizard, apex creates its own processes for optimistic locking. But when creating a form on a table, it doesn't create the processes. I suppose I need to create them manually.
Can anybody show me the steps?
Thanks!

Scott,
Thanks once again.
2 things:
My understanding is that I can't change the error message, and that if I want to customize the error message, I need to create my own process for checksum. Is this true? If so, what is the easiest way of doing this?
I realized it returns an error message and the changes the user made gets lost if he went out for lunch and somebody else made an update on that record. What can I do so the user doesn't lose the data?
Thanks,

Similar Messages

  • Data Concurrency and Consistency ( SCN , DATA block)

    Hi guys, i am getting very very very confused about how oracle implement consistency / multiversioning with regards to SCN in a data block and transaction list in the data block..
    I will list out what i know so you guys can gauge me on where i am..
    When a SELECT statement is issued, SCN for the select query is determined. Then Blocks with higher SCN are rebuilt from the RBS.
    Q1) The SCN in the block implied here - is it different from the SCNs in the transaction list of the block ? where is this SCN store ? where is the transaction list store ? how is the SCN of the block related with the SCNs in the transaction list of the block ?
    Q2) can someone tell me what happen to the BLOCK SCN and the transaction list
    of the BLOCK when a transaction start to update to a row in the block occurs.
    Q3) If the BLOCK SCN reflects the latest change made to the block and If the SCN of the block is higher then the SCN of the SELECT query, it means that the block has change since the start of the SELECT query, but it DOESNT mean that the row (data) that the SELECT query requires has changed.
    Therefore why cant ORACLE just check to see whether the row has changed and if it has, rebuilt a block from the RBS ?
    Q4) when ORACLE compares the BLOCK SCN, does it only SCAN for the BLOCK SCN or does it also SEARCH through the TRANSACTION LIST ? or it does both ? and why ?
    Q5) is transaction SCN same as Transaction ID ? which is store in the RBS , the transaction SCN or ID ?
    Q6) in short i am confuse with the relationship between BLOCK SCN, transaction list SCN, their location, their usage and relationship of the BLOCK SCN and transaction list when doing a SELECT, their link with RBS..
    any gurus clear to give me a clearer view of what is actually happening ?

    Hi Aman
    Hmm agreed.So when commit is issued , what happens at that time?Simply put:
    - The SCN for the transaction is determined.
    - The transaction is marked as committed in the undo header (the commit SCN is also stored in the undo header).
    - If fast cleanout takes place, the commit SCN is also stored in the ITL. If not, the ITL (i.e. the modified data blocks) are not modified.
    So at commit, Oracle will replace the begin scn in the ITL with this scn
    and this will tell that the block is finally committed is it?The ITL does not contain the begin SCN. The undo header (specifically the transaction table) contains it.
    I lost here.In the ITL , the scn is transaction SCN or commit scn?As I just wrote, the ITL contains (if the cleanout occured) the commit SCN.
    This sounds like high RBA information?What is RBA?
    Commit SCNThis is the SCN associated with a committed transaction.
    Begin SCNThis is the SCN at which a transaction started.
    Transaction SCNAs I wrote, IMO, this is the same as the commit SCN.
    Also please explain that what exactly the ITL stores?If you print an ITL slot, you see the following information:
    BBED> print ktbbhitl[0]
    struct ktbbhitl[0], 24 bytes     @44
          struct ktbitxid, 8 bytes    @44
             ub2 kxidusn              @44       0x0009
             ub2 kxidslt              @46       0x002e
             ub4 kxidsqn              @48       0x0000fe77
          struct ktbituba, 8 bytes    @52
             ub4 kubadba              @52       0x00800249
             ub2 kubaseq              @56       0x3ed6
             ub1 kubarec              @58       0x4e
          ub2 ktbitflg                @60       0x2045 (KTBFUPB)
          union _ktbitun, 2 bytes     @62
             b2 _ktbitfsc             @62       0
             ub2 _ktbitwrp            @62       0x0000
          ub4 ktbitbas                @64       0x06f4c2a3- ktbitxid --> XID, the transaction holding the ITL slot
    - ktbituba --> UBA, used to locate the undo information
    - ktbitflg --> flags (active, committed, cleaned out, ...)
    - _ktbitfsc --> free space generated by this transaction in this block
    - _ktbitwrp+ktbitbas --> commit SCN
    HTH
    Chris

  • Lock Data: Enqueue and Dequeue

    Im trying to lock data from vb.net but it didnt work out.
    I pass the variable to my function module and inside the function contains below codes.
    eg:
    CALL FUNCTION 'ENQUEUE_EZCOL06'
       EXPORTING
         MODE_ZCOL06          = 'E'
         MANDT                = SY-MANDT
         ZBUKRS               = code1
         ZGJAHR               = code2
         ZRPTNO               = code3     
         _SCOPE               = '2'
         _WAIT                = 'X'
       EXCEPTIONS
         FOREIGN_LOCK         = 1
         SYSTEM_FAILURE       = 2
         OTHERS               = 3.
    I open multiple screen (VB.net) but still it didnt lock the data. I dont know where it gone wrong. But when I try in SAP itself it works. I open multiple session and it detects and it locks the data.
    Please help.
    Thank you.

    Hi zhenglin gu,
    Thanks for replying.
    Yup, i tried your solution but it didnt work out also.
    Then I check for the Allow RFC (Remote Function Call). Meaning to say, I can access the function module from the VB.Net. I thought it's going to work but it didnt. I change from cumulative to not cumulative. After that, I also check in the SM12 (Lock Entries). There is no lock entries.
    Anyone could help me?
    Thank you.
    Regards.

  • FM to lock data element and messages

    Hi All,
    I need a FM to enque data element and messages for translation.
    I have found out one FM for ABAP program texts - ENQUEUE_EABAPTEXTE.
    Can you please tell me the corresponding ones for data element and messages.
    Thank you.
    Ajith

    Hi Krishna,
    Use function modules    enqueue_<<lock object>>u2019 and dequeue_<<lock object>>u2019
    With Regard's
    SHAIK.

  • Optimistic Lock with Parent and Child relationships

    Hi,
    I just have a question regarding optimistic locking. We have a scenario
    where a parent object has many child objects. Both the parent and the
    child objects have a jdolockx column in the database/jdo file.
    It appears that whenever you add a new child to the parent the parent's
    optimistic lock counter is also updated.
    eg
    parent.getChildren().add(child);
    child.setParent(parent);
    Why does this occur? There is no change made to the database table for
    the parent, except for the jdolockx column. Is there something that I can
    do to stop the lock count from incrementing when I child is added?
    We have a scenario where we have many threads of execution wishing to add
    children to a single parent. The parent itself isnt modified but this
    operation fails due to the parent lock counter being incremented.
    Any help would be appreciated
    Thanks
    Luke

    There is state image indicator in Kodo 3 which has more locking options
    beyond a simple number:
    http://solarmetric.com/Software/Documentation/3.0.1/docs/ref_guide_mapping_versionind.html#state-image
    In addition, you can plug your own version indicator.
    Our default optimistic locking avoids the problem of users having no
    idea what is -actually- in the collection/set at any given time.
    Inconsistencies can occur at the datastore level (user 1 adds
    object a to collection, user 2 removes a, user 1 adds object b... which
    should actually be in the DB? {a,b} or or {a}? This is one of the
    many ways in which not tracking changes to a collection/set can be
    hazardous).
    On locking exceptions, errors could be handled in some appropriate
    function (i.e. refresh, re-apply changes if applicable/safe,
    and commit).
    Luke wrote:
    Hi,
    I just have a question regarding optimistic locking. We have a scenario
    where a parent object has many child objects. Both the parent and the
    child objects have a jdolockx column in the database/jdo file.
    It appears that whenever you add a new child to the parent the parent's
    optimistic lock counter is also updated.
    eg
    parent.getChildren().add(child);
    child.setParent(parent);
    Why does this occur? There is no change made to the database table for
    the parent, except for the jdolockx column. Is there something that I can
    do to stop the lock count from incrementing when I child is added?
    We have a scenario where we have many threads of execution wishing to add
    children to a single parent. The parent itself isnt modified but this
    operation fails due to the parent lock counter being incremented.
    Any help would be appreciated
    Thanks
    Luke
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Time wait - line lock - data concurrency - Solved with workaround

    Hi.
    A session inserts a line in a table and it does not make commit.
    Another session makes another insert in the same table, with the same value for primary key and, because of the Lock, it is waiting for one commit or rollback of the first session, and only after this it's get a error message.
    Exists some way to make with that the error message is shown immediately, without waiting for commit or rollback of the other session (first session)?
    PS.:
    But I need to continue with READ COMMITTED (statement) isolation level, because the SERIALIZABLE (transaction) would generate many locks.
    Message was edited by:
    ARF
    Message was edited by:
    ARF

    Using a sequence for a PK will not solve your problem since I believe that you would still need a unique index (perhaps unique constraint) on the business value to prevent duplicates. Using a sequenced generated value for the PK would just move the problem to this second index unless the current PK is just a sequential number in which case why can't the value have gaps?
    I know a system that uses a sequence generated value for its invoice numbers assigned at shipping time. There are gaps. When the auditors questioned it (after 8 years of being this way) it was pointed out that a sequential set of invoice numbers does not prove that an invoice that should have been generated was not skipped or that the invoices themselver are complete. The real audit trail is the report that show for every item on a sales order every item was shipped and invoiced. The cross reference report is the validation. The invoice numbers are meaningless. Sequential numbers are a false sense of security.
    Possible alternates are to use a sequence as the PK (or a UK) and to update a second key column sequentially via batch (update table in sequence value order assigning sequential value via function which adds one to previous value on each use) Since only one process will perform the assignment there will be no gaps.
    HTH -- Mark D Powell --

  • High concurrency optimistic locking

    Hi there,
    We have an EJB method that roughly does the following; we have a number of buckets that may or may not be full. If one or more are not full we want it to find the one with the most space available and add the item there. Our main problem here is that this method can be called upwards of 1000 times per second and we're now looking for an efficient way to solve the concurrency issue of two different calls both thinking bucket X has space left even though one of the two calls will fill it up :
    THREAD 1 : findEmptyBucket() returns BUCKET1 (1 SPOT LEFT)
    THREAD 2 : findEmptyBucket() returns BUCKET1 (1 SPOT LEFT)
    THREAD 1 : addItemToBucket(BUCKET1) <- FULL NOW
    THREAD 2 : addItemToBucket(BUCKET1) <- WRONG
    Since only optimistic locking is available in the spec for some reason I think the "EJB3" approach is basically (pseudoish) :
    while(!succeeded) {  
        try {  
            Bucket b = findEmptyBucket(...); // Will throw OptimisticLockException?  
            addItemToBucket(b, item);  
            succeeded = true;  
        catch(OptimisticLockException e) {}  
    } This seems horribly inefficient for a call that is almost guaranteed to require dozens of retries during peak hours. Is there any way to optimize this in such a way that we don't have to use optimistic locking? We're trying to solve this without using vendor specific solutions but EJB3 seems to lack the necessary functionality. Suggestions definitely welcome, evne if they are "that's the only way to do it" ;)
    Thanks!

    I think the OptimisticLockingException is thrown after-the-fact. So, if the addItemToBucket() method does a commit (flush), it will generate the exception rather than the find method. Otherwise, if there is no explicit commit call, the exception will be thrown when the EJB method that holds the while loop returns.
    If performance is critical, maybe a Stateful SessionBean with a Stateless Facade would work better. Create a Stateless SessionBean with an addItem() method and a reference to a single stateful bean. The implementation of the stateful session bean would be something like the following standalone program. The stateful bean would have an addItem() method too, but would keep track of a pool of resources internally.
    class ItemBucket { Item i; }
    class Item { String data; }
    class NoBucketsAvailableException extends Exception {}
    public class bucket {
        final static int POOL_SIZE = 4;
        ItemBucket[] bucketPool = new ItemBucket[POOL_SIZE];
        Object[] bucketLocks = new Object[POOL_SIZE];
        void initBucketPool() {
         for(int i=0; i<POOL_SIZE; i++)  {
             bucketPool[i] = new ItemBucket();
             bucketLocks[i] = new Object();
        void addItemToEmptyBucket(Item _i) throws NoBucketsAvailableException {
         int i=0;
         for(; i<POOL_SIZE; i++) {
             if( bucketPool.i == null ) { // possible empty bucket
              synchronized(bucketLocks[i]) {
              if( bucketPool[i].i == null ) {  // double checked locking
                   bucketPool[i].i = _i;
         if( i >= POOL_SIZE) { throw new NoBucketsAvailableException(); }
    public static void main(String[] args) {
         bucket app = new bucket();
         app.initBucketPool();
         Item item = new Item();
         item.data = "test";
         try {
         app.addItemToEmptyBucket(item);
         catch(NoBucketsAvailableException exc) {}

  • Shuttle item and optimistic lock

    Hi everyone,
    I need to use a shuttle item to insert/update some data in a table. Because of that, I need to have a pl/sql process that will have the insert or update commands, so no DML allowed in my app page. By doing this, I lose the optimistic lock implemented within the DML process, so I've been searching and reading on how to accomplish this manually.
    I followed this post (Re: Optimistic locking on manual non-tabular form among others but it doesn't work properly.
    Is there another way to get the optimistic lock manually?
    Or better yet, is there a way to update a table from a shuttle item with DML?
    btw, i'm using apex 4.1.
    Thanks!
    Elena.

    Hello Elena,
    >> tab := apex_util.string_to_table (:p1_multiple_item);
    Yes. This is what I meant in parsing the shuttle value.
    >> Maybe I'm wrong, but this implies no use of DML, doesn't it?
    You are not wrong, although the correct term would be Automatic DML, which is a built-in APEX process (The term DML refers to any insert/update/delete database operation, regardless of APEX).
    You didn’t specify if you are familiar with the Optimistic Locking algorithm (which, BTW, pertains only to update data). In any case, my suggestion to you is to use the SQL Workshop to generate a package on your relevant table, and examine the update procedure that was generated. This procedure implements the Optimistic Locking algorithm and can be a great starting point for you to adapt it to your specific needs.
    You can generate the package using SQL Workshop ==> Object Browser ==> Create ==> Package ==> Package with methods on database table(s) .
    Hope it helps,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

  • STS u0096 Status buttons and locked data after approving

    Hello!
    I have some difficulties to customize STS and to lock data with the “Approve” status:
    With a bottom-up organization, a low level (User A) sends for approval to his superior (User B), then the superior approves. Then the data are normally locked for User A.
    But User A has always the possibility to click on the button “Open planning” and key-in/save data on the input form. And I don’t understand what is wrong.
    I hope my explanation is clear and sufficient.
    Thank you in advance for your help.
    Cécile

    Thank you for your answer.
    According the OSS note, my user has only the authorization R_STS_PT and it’s a bottom-up session. But I must use Header selections for the planning session? I have done some tests with this option and it wasn’t conclusive. At this moment I have no restriction/value in the option Define Header Chars for planning session.
    And I don’t understand the sdn topic link. There is no relation with my problem?

  • STS not locking data and layout

    Hi, we are trying to use STS for approval.  We have it configured and it seems to work fine but it does not lock the data when it is "approved".  I check the tables UPS_LOCKS and UPS_HASH and the seem in sync, after the approval there is an entry in UPS_LOCKS.  I tried a data slice and it locks fine.  For the hierarchy, I am using a reference infoobject called ZPLNT_CO in which the actual hieraercy is build on 0COMP_CODE, could this be the problem?, although it did import properly into STS . 
    Does the authorization objects need to have an activity other than 16?
    Any other suggestions?  Thanks in advance, Scott

    We have not found that STS is very satisfactory for locking submitted data on status change. It depends somewhat on your organisation and how your planners can work in the organisation: for example take a look at previous thread
    [STS and locking|https://forums.sdn.sap.com/click.jspa?searchID=9479206&messageID=4221273].
    So STS appears to lock data in all units for which a user plans, and other users may not be affected by the lock. So it appears to work best if there is a one-to-one relation between users and units which they plan.
    I could be wrong, but that has been my impression.
    (We are using SAP GUI entry of data).
    Regards
    Stephen

  • Method of fetching Account status and user locked date in Portal.

    Hi,
    Can anyone suggest me the method name  in UME API in Sap Ep for fetching User Account Status and Last User Locked Date. Or suggest a related code for it.
    user database is LDAP.
    Thanks

    Hi Abhai,
    The class (actually Interface) you're looking for is IUserAccount. You can get this from the IUser by using the method getUserAccounts().
    The IUserAccount provides all sort of methods like lockDate(), isLocked(), getLockReason().
    See more in https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/library/ep/_d-f/ep%206.0%20sp2%20usermanagement%20public%20api
    Best regards,
    Amit

  • Optimistic locking and HTML DB checksum calculation

    I create a form for fetching and updating row from a database table. I use Automated Row Fetch for fetching row. But for updating row I must use a procedure from a package, not Automatic Row Processing (DML).
    And my question is: how I can implement optimistic locking in this way?
    Automated Row Fetch already calculated checksum and stored it in p_md5_checksum hidden field, can I get calculated value of checksum from p_md5_checksum?
    How I can calculate checksum by myself for compare with value from p_md5_checksum?
    What algorithm uses HTML DB for calculate checksum in Automated Row Fetch and Automatic Row Processing (DML) components?

    I have read this topic already. It's recommended to build own functionality for calculate checksum, but Automated Row Fetch already calculated checksum and stored it in p_md5_checksum hidden field.
    I also created my own function, for example for table dept:
    create or replace function BUILD_DEPT_MD5 (
    P_DEPTNO in number,
    P_DNAME in varchar2 default null,
    P_LOC in varchar2 default null,
    P_COL_SEP in varchar2 default '|') return varchar2 is
    begin
    return utl_raw.cast_to_raw(dbms_obfuscation_toolkit.md5(input_string => P_DEPTNO || P_COL_SEP || P_DNAME || P_COL_SEP || P_LOC));
    end BUILD_DEPT_MD5;
    but checksum values what calculated with this function is not equal with checksum value calculated by Automated Row Fetch.
    I shall specify:
    I need to use Automated Row Fetch for get row from table.
    I can not use Automatic Row Processing (DML) for update row, I need use PL/SQL procedure for this.
    I want implement optimistic locking and I want use for this a checksum value, what already calculated by Automated Row Fetch. I need to know how I can get this checksum value and I need to know algorithm, which Automated Row Fetch uses for checksum calculation.

  • Lock-In Amplifier and offline data processing

    Hi everyone,
    I've been successfully using the Lock-In Amplifier to do live data processing. The processed Lock-In outputs and the frequency values are then saved. Recently it has turned out that the real acquisition capabilities needed mean that online processing is not possibe. (As 4 channels are being simultaneously sampled each at 4Mhz and acquiring for several seconds.) I have built the Lock-In Amplifier into an offline processing VI where I strip out the arrays for Channel 0 (Signal) and Channel 1 (Reference) and send chunks of data to the Lock-In. I wanted to check that the Lock-In doesn't have any problems working offline? Are there any other things I need to know for offline processing?
    Many thanks

    Hi,
    I've not personally had the change to use Lock In Amplifiers with our hardware yet, but from searching through the LabVIEW developer zone I came across this example VI, I hope it's some help to you: http://zone.ni.com/devzone/cda/epd/p/id/4532
    All the best,
    Applications Engineer

  • I have a ipod touch that has been locked by itunes and it says i must reset the data before i unlock it. Is there a way to back it up before i reset it or to avoid reseting it at all?

    I have a ipod touch that has been locked by itunes and itunes says i must reset the ipod to unlock it. Is there a way to back it up on a hard drive or icloud before I reset it or avoid reseting it all? thanks

    If you previous synced to the computer then you may be able to recovery use of the iPod without erasing the iPod by following the instructions here:
    Disabled Recovery-must use syncing computer.
    Otherwise y have to erase the iPod
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • 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