How to avoid waiting forever when Updating a locked row ?

Hi all,
We have front-end application (ADF BC) on Oracle 10g database. From the adf we call stored procedure that execute the dml below :
UPDATE DOC_NUMBER SET doc_nbr = doc_nbr + 1
WHERE REGISTER = pRegsCode AND doc_code = pDocCode AND
loc_code = pLocCode AND
          doc_year = vDocYear
RETURNING TO_CHAR(doc_nbr, '0000000') INTO vDocNo ;
Sometimes, this statement wait very long, I see in EM Top SQL that the Wait value = 99.66%. I assume this is caused by another user run same program and Not Commit.
So the question is :
1) How to make the 'UPDATE...' statement only wait 10 seconds, if fail to get the lock then time out ?
2) If a user run the stored proc and do not Commit, how to make the transaction 'Expires' after 10 seconds so that it does not block other users ??
FYI, the COMMIT part is not in the stored proc, it is done in ADF level.
That is why if there is error in ADF after executing the stored proc, the transaction left Uncommitted
Thank you very much for your help,
xtanto

This is not an Oracle issue and cannot really be sensible addressed (if at all) at Oracle level.
How is Oracle suppose to know that after 10 seconds (or minutes) to "expire" (rollback) all uncommitted transactions? This deals with the client side of the client-server. How to interact with the client. When to determine that the user on the client is idle. Etc.
There is no triggering/event mechanism I know of inside an Oracle server session that can be fired after the Oracle session has been idle for a period of time. The closest to that is DCD (Dead Connection Detection) - which is n.a. as the client is not dead, just idle.
The application controls and manages the the user interaction. It is in a far better position to realise that the user is not responding, and then to rollback its Oracle session.
This should be therefore done by the client and not Oracle. In its simplest form, you have a session handle in the client for your Oracle session. You create a global boolean variable (called something like openTransaction) in the application. This is set to TRUE when a transaction (e.g. select for update, insert, updare or delete) is started.
An application timer runs every n number of seconds. When it runs, it checks openTransaction. If true, it issues a ROLLBACK statement on that session handle.
This should do the trick.. in large hammer fashion way. Any such implementation will need careful thought and consideration of the actual business requirements and business process flow.
It is very seldom that in business, clerks John and Jane will be working with the very same client file/invoice/whatever at the exact same time. And when there is conflict, you want to make sure that either Jane or John works on that at a time.
So before even looking for a technical solution to your problem, I would first determine what the business process flow are and the boundaries of the business transaction, in order to realise a solution.

Similar Messages

  • Avoiding concurrency errors when updating a database through AJAX

    What are some strategies for avoiding concurrency errors when updating a database through AJAX. That is, in cases where a given user could attempt to modify the same row in the database with simultaneous requests (say, that he updates one column with information with an AJAX call, then immediately submits a form that updates the same row), what are some good ways yo prevent the two updates from colliding? On the JavaScript side one might make the AJAX call synchronous, but I question whether that is the best way to do it. Has anyone else confronted this?

    Well, since no one seems to have any ideas so far, I'll throw in my two cents worth.
    I'm not too familiar with AJAX so my advice may be limited.
    I suggest you do a google search on Optimistic concurrency database to get some ideas on how to handle it.
    If your update/insert/delete query is thread safe, then even if the same user double clicks the button fast enough to immediately have another update to the same record, then the first update will complete before the second one is carried out. Therefore no harm is done since he is just updating the same record. Since a typical update/insert/delete takes only a few milliseconds (querying may take a lot more time), its not likely he can click the button that fast. (I assume your using connection pooling for speed).
    The trouble comes up when two people call up data from the same record in different browsers. The first one updates/inserts/deletes the record. Now the other user is looking at old data. When he updates/inserts/deletes, there is a problem. One way to handle this is to keep a copy of all the fields from that record in each user's session scope when they first fetch it from the database (example: oldName). Then when you go to update some time later, to this:
    sql= update person set name=newValue where personID=3344 and name=oldName
    Note oldName is from session scope.
    If name in the database has changed, the update will not occur and will return 0 records updated. If it didn't change, it will update.
    Note your update function should not throw an exception if it cant update, it should return false. Return true if it worked.
    Example: public boolean updateName(String name)
    Similiarly, your insert should not throw an exception if the record already exists, it should return false meaning it cant insert.
    Exaple: public bolean insertName(String name). Same thing with delete function.
    If a record cant be updated due to someone else updating the record while the user was looking at data, return a message that it wasn't updated due to that problem. Then show the user the new value in the database ask him if he wants to overwrite the new change.
    Note even if you show 100 records on the JSP, only update the ones that have changed and not all 100. This way, its not likely he has updated the same records someone else has altered. Less likely a colision compared to updating all 100.
    If your updating/inserting/deleting more than 1 record (say, 3), then you should look into setting up a transaction in addition to all the above and rolling back all of them if one fails.
    Reading the section on databases from http://www.javapractices.com/home/HomeAction.do may also help.

  • How to avoid the dialogue when converting from context menu

    This is a follow-up to http://forums.adobe.com/message/2016146#443364 which was locked due to a bug.
    i would like to know how i can avoid the 'save as' dialogue when using the context menu to convert a word file to pdf using windows XP/acrobat 8/word 2007.
    so far, it always prompts me for the filename, which is annoying as it does not allow me to batch-convert several files and let the thing run its course.
    the solution provided by Steve in the other thread does not work - even if the plugin from word does not propt for a filename, it still does when triggered from explorer/context menu.
    so back to square one: how to avoid that dialogue when not opening word at all?
    cheers, thanks for any help. michael

    For a permanent change, START>PRINTERS>right click on Adobe PDF printer and select properties>General>Printing Preferences>Adobe PDF Settings. Under the settings tab, uncheck the box related to asking for a name. Pretty sure that is the location, but it may vary with version.

  • How to avoid launching Labview when invoking VI by Teststand

    Hi, friends.
    I'm a learner of teststand. I wrote some VIs by Labview. Now I want to invoke them in teststand environment. But when I run the sequence. Labview will be automatically launched. How to avoid launching Labview when I run the sequence?
    Thanks.
    Solved!
    Go to Solution.

    I'm not sure that I follow what you are saying..  But it sounds like when the VI is called, the LabVIEW development software is started and you want to avoid that.
    If you create an executable or dll and call that from within TestStand, it should not call the development environment.  You would need to have the LabVIEW run-time engine installed on the target PC. 
    It has been many years since I've used TestStand with LV, so my memory may not be accurate.  I think the above had worked for me.  However, it seems that I recall something about having the LV code in debug mode causing it to open the development environment.... but it's a distant memory.    You're not using breakpoints where the LV VI is being called, are you?
    R

  • How to avoid data repetation when using select statements with innerjoin

    how to avoid data repetation when using select statements with innerjoin.
    thanks in advance,
    satheesh

    you can use a query like this...
      SELECT DISTINCT
             frg~prc_group1                  "Product Group 1
             frg~prc_group2                  "Product Group 2
             frg~prc_group3                  "Product Group 3
             frg~prc_group4                  "Product Group 4
             frg~prc_group5                  "Product Group 5
             prc~product_id                  "Product ID
             txt~short_text                  "Product Description
    UP TO 10 ROWS
    INTO TABLE l_i_data
    FROM
    Joining CRMM_PR_SALESG and
    COMM_PR_FRG_ROD
    crmm_pr_salesg AS frg
    INNER JOIN comm_pr_frg_rod AS prd
    ON frgfrg_guid = prdfragment_guid
    Joining COMM_PRODUCT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_product AS prc
    ON prdproduct_guid = prcproduct_guid
    Joining COMM_PRSHTEXT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_prshtext AS txt
    ON prdproduct_guid = txtproduct_guid
    WHERE frg~prc_group1 IN r_zprc_group1
       AND frg~prc_group2 IN r_zprc_group2
       AND frg~prc_group3 IN r_zprc_group3
       AND frg~prc_group4 IN r_zprc_group4
       AND frg~prc_group5 IN r_zprc_group5.
    reward it it helps
    Edited by: Apan Kumar Motilal on Jun 24, 2008 1:57 PM

  • Ipod touch stuck in waiting mode when updating or downloading an app?

    Ipod touch stuck in waiting mode when updating or downloading an app?

    See here: https://discussions.apple.com/thread/4233381?tstart=0
    B-rock

  • How to avoid safety warning when opening a pdf from an link in another pdf?

    I make pdf in Acrobat with links to other pdf files av have made. When i try to click a link to open the pdf, i get the safety question if trust it or if i will block it. How to avoid that question all the time?

    Hello Kvalitetetsansvarlig
    Try adding the PDF to the trust location in Acrobat
    Edit -> Preferences-> Security (Enhanced), Click on "Add File", and browse to your file.
    Click on "OK" button and check.
    Regards,
    Deepak

  • How to avoid clear record when tab pages changes

    Hi All
    I am using oracle forms 10g and db 10g.
    I have created a form with four tab pages. Namely "EXPENSE" , "AMOUNT_DETAILS", "SUPPLIER" , "ACCOUNT".
    When i enter a data in page 1 ie Expense and move to next page page2 "AMOUNT_DETAILS", and enters data in page3 "SUPPLIER" and when i come back to page1 "EXPENSE" and also Page2 "AMOUNT" the data get cleared in Tab pages. There is no data again i need to enter the data manually.
    Can any one suggest me how to avoid this clear data.
    Thanks & Regards
    Srikkanth

    Hi,
    Thanks once again for your quick response.
    I have checked it , i was working with oracle apps.Now i have entered all the datas in the four tab and press save button in the screen at that time also the data get cleared.Can you please tell is there any work around for this.
    regards
    Srikkanth

  • How to avoid the prompt when verifing signature?

    I sign the doc with my cert.
    The cert is not trusted by Acrobat/Reader itself so when i try to verify the signature Acrobat/Reader will prompt the user cert is not trusted.
    My question is how to avoid this prompt through Acrobat SDK or how to add my cert to trusted cert list through Acrobat SDK?
    Thanks.

    Patrick Leckey wrote:
     You will also see the BER Decoding error when you have a self-signed peer-to-peer cert in your Windows Cert Store, even if it is not the signature you are using to sign.
    Start > Run > certmgr.msc
    Look for any certs that have "peer-to-peer" in the Intended Purpose column
    Remove that cert
    Restart Acrobat
    Give that a shot.
    Patrick,I have not found the Intended purpose of cert names "peer-to-peer".
    But I have just found the cert which will cause the signature failure.
    The key is the cert can not be removed.
    I'm very curious that why a cert has no relationship with the signature could cause the signature failure?
    Is it a BUG of Acrobat/Adobe Reader?
    If not how can i operate successfully?
    Thanks.

  • How to return all fields when updating?

    When I update a lead, it only returns fields that are modified but not all fields in the XML.
    I noticed the LeadID and LeadFullname values are still being returned when updating which is good.
    How can I make it so it will return ALL fields that have values and not just the modified ones when updating?
    Thanks

    I have to query it after getting it back from the queue.

  • How to avoid opening photos when connecting a camera

    how can I avoid opening photos when connecting a camera?

    Connect the Camera.
    Launch Image Capture (in the Applications Folder)
    You can set what happens when you connect this device in the lower left of the Image Capture window.

  • How to avoid water damage when installing invisible shield

    Just wondering what you have to do to avoid water damage when installing Zagg invisible shield? What precautions should I take so that I do not damage the iPhone when installing Zagg Invisible shield?
    Thanks and I look forward to your replies.
    ...B

    Hi BGmail,
    I would stay away from invisible shield by zagg or similar products. I tried it, waste of £15, could have got myself a dock stand for my phone for that ****!! The problem with IS(invisible shield) is that the screen protector has a rubber feel which makes it annoying when swiping your finger on it + it's not scratch proof at all!! Mine scratched 2 days after the installation so badly that I had to remove it. The back it's hard to apply, does not cover everything you'd like to, also a dust trap that could get between tha film and the phone causing it to scratch, some people reporting the film going yellow after a while(on white iPhones).
    What I think of IS: A poor american product heavily/aggressive advertised!! Mine is off, using a hard clear plastic shell and a good screen protector, might look bulky but it's safe, only using the shell while at work, the iPhone is pretty tough, don't forget.
    Your choice... Good luck !!

  • How to avoid system slow when login first time  everyday

    if login system first time every day, it will be very slow for loading web application.
    I think maybe it 's  reload cache every night or by a certain perods of time.
    how to avoid this situation. or set cache reload a time per week?
    Thanks.

    Terry,
    I would confirm your application pools are set up as suggested in the install documentation.  This should resolve your issue.
    Thanks,
    Drew

  • HT4528 How do I disable Siri when in the lock screen?

    I tried Settings, General, Passcode Lock, and turned off Siri when locked but, when in the locked screen if you hold down the square button Siri still comes on. All day I can here my phone in my pocket turning on and off and telling me it didnt understand what I said.

    That's not Siri, that's Voice Control which is what you get when you turn Siri off. Perhaps a different pocket or a belt clip. If things keep pushing that hard against the screen of your phone in your pocket, eventually, you could do some damage.
    Best of luck. 

  • How to avoid mutating error when insert or update record

    Hi ,
    I have one transaction table which is having some detail record under one transaction number, after the one transaction number is over by insert or update, i
    want to check the total amounts of one flag should be matched on same table if it is not then give error message. But i am getting mutating error on insert or update event trigger on statement level trigger on above table.
    Is there any other way to avoid mutating error to solve the above problem or some temp table concepts to be used. help me its urgent.
    Thanks in advance,
    Sachin Khaladkar
    Pune

    Sachin, here's as short of an example as I could come up with on the fly. The sample data is ficticious and for example only.
    Let's say I need to keep a table of items by category and my business rule states that the items in the table within each category must total to 100% at all times. So I want to insert rows and then make sure any category added sums to 100% or I will rollback the transation. I can't sum the rows in a row-level trigger because I'd have to query the table and it is mutating (in the middle of being changed by a transaction). Even if I could query it while it is mutating, there may be multiple rows in a category with not all yet inserted, so checking the sum after each row is not useful.
    So here I will create;
    1. the item table
    2. a package to hold my record collection (associative array) for the trigger code (the category is used as a key to the array; if I insert 3 rows for a given category, I only need to sum that category once, right?
    3. a before statement trigger to initialize the record collection (since package variables hang around for the entire database session, I need to clear the array before the start of every DML (INSERT in this case) statement against the item table)
    4. a before row trigger to collect categories being inserted
    5. an after statement trigger to validate my business rule
    I then insert some sample data so you can see how it works. Let me know if you have any questions about this.
    SQL> CREATE TABLE item_t
      2   (category  NUMBER(2)   NOT NULL
      3   ,item_code VARCHAR2(2) NOT NULL
      4   ,pct       NUMBER(3,2) NOT NULL);
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE trg_pkg IS
      2    TYPE t_item_typ IS TABLE OF item_t.category%TYPE
      3      INDEX BY PLS_INTEGER;
      4    t_item       t_item_typ;
      5    t_empty_item t_item_typ;
      6  END trg_pkg;
      7  /
    Package created.
    SQL> SHOW ERRORS;
    No errors.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER item_bs_trg
      2    BEFORE INSERT
      3    ON item_t
      4  BEGIN
      5    DBMS_OUTPUT.put_line('Initializing...');
      6    trg_pkg.t_item := trg_pkg.t_empty_item;
      7  END item_bs_trg;
      8  /
    Trigger created.
    SQL> SHOW ERRORS;
    No errors.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER item_br_trg
      2    BEFORE INSERT
      3    ON item_t
      4    FOR EACH ROW
      5  BEGIN
      6    trg_pkg.t_item(:NEW.category) := :NEW.category;
      7    DBMS_OUTPUT.put_line('Inserted Item for Category: '||:NEW.category);
      8  END item_br_trg;
      9  /
    Trigger created.
    SQL> SHOW ERRORS;
    No errors.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER item_as_trg
      2    AFTER INSERT
      3    ON item_t
      4  DECLARE
      5    CURSOR c_item (cp_category item_t.category%TYPE) IS
      6      SELECT SUM(pct) pct
      7        FROM item_t
      8       WHERE category = cp_category;
      9  BEGIN
    10    DBMS_OUTPUT.put_line('Verifying...');
    11    FOR i IN trg_pkg.t_item.FIRST..trg_pkg.t_item.LAST LOOP
    12      DBMS_OUTPUT.put_line('Checking Category: '||trg_pkg.t_item(i));
    13      FOR rec IN c_item(trg_pkg.t_item(i)) LOOP
    14        IF rec.pct != 1 THEN
    15          RAISE_APPLICATION_ERROR(-20001,'Category '||trg_pkg.t_item(i)||' total = '||rec.pct);
    16        END IF;
    17      END LOOP;
    18    END LOOP;
    19  END item_as_trg;
    20  /
    Trigger created.
    SQL> SHOW ERRORS;
    No errors.
    SQL> INSERT INTO item_t
      2    SELECT 1, 'AA', .3 FROM DUAL
      3    UNION ALL
      4    SELECT 2, 'AB', .6 FROM DUAL
      5    UNION ALL
      6    SELECT 1, 'AC', .2 FROM DUAL
      7    UNION ALL
      8    SELECT 3, 'AA',  1 FROM DUAL
      9    UNION ALL
    10    SELECT 1, 'AA', .5 FROM DUAL
    11    UNION ALL
    12    SELECT 2, 'AB', .4 FROM DUAL;
    Initializing...
    Inserted Item for Category: 1
    Inserted Item for Category: 2
    Inserted Item for Category: 1
    Inserted Item for Category: 3
    Inserted Item for Category: 1
    Inserted Item for Category: 2
    Verifying...
    Checking Category: 1
    Checking Category: 2
    Checking Category: 3
    6 rows created.
    SQL>
    SQL> SELECT * FROM item_t ORDER BY category, item_code, pct;
      CATEGORY IT        PCT
             1 AA         .3
             1 AA         .5
             1 AC         .2
             2 AB         .4
             2 AB         .6
             3 AA          1
    6 rows selected.
    SQL>
    SQL> INSERT INTO item_t
      2    SELECT 4, 'AB', .5 FROM DUAL
      3    UNION ALL
      4    SELECT 5, 'AC', .2 FROM DUAL
      5    UNION ALL
      6    SELECT 5, 'AA', .5 FROM DUAL
      7    UNION ALL
      8    SELECT 4, 'AB', .5 FROM DUAL
      9    UNION ALL
    10    SELECT 4, 'AC', .4 FROM DUAL;
    Initializing...
    Inserted Item for Category: 4
    Inserted Item for Category: 5
    Inserted Item for Category: 5
    Inserted Item for Category: 4
    Inserted Item for Category: 4
    Verifying...
    Checking Category: 4
    INSERT INTO item_t
    ERROR at line 1:
    ORA-20001: Category 4 total = 1.4
    ORA-06512: at "PNOSKO.ITEM_AS_TRG", line 12
    ORA-04088: error during execution of trigger 'PNOSKO.ITEM_AS_TRG'
    SQL>
    SQL> SELECT * FROM item_t ORDER BY category, item_code, pct;
      CATEGORY IT        PCT
             1 AA         .3
             1 AA         .5
             1 AC         .2
             2 AB         .4
             2 AB         .6
             3 AA          1
    6 rows selected.
    SQL>

Maybe you are looking for

  • How can I transfer my iTunes library and playlists from one computer to another?

    How can I transfer my iTunes library and playlists from one computer to another?

  • T510i eSATA/USB3.0 combo port: eSATA cable doesn't fit

    Hello, my T510i has a eSATA/USB3 combo port. I assume that an eSATA plug should fit in there. But the eSATA cable I bought doesn't fit. (It fits into my external hard drives eSATA port, though.) Can you help me with this, please? Thanks a lot in adva

  • WSRP: images do not show

    I have implemented a richt text editor WSRP portlet (webcenter) in Portal by registering as a WSRP provider. Though the portlet is working, images on the buttons do not show. We had this problem before with WSRP portlets, but never solved it (just st

  • Populate vo values in multi colum format

    Hi, I created a VO and now i want to present the values in multi column format with radio button for each value fetched from query . I tried using message component layout.But i was not successful in doing . I want in the following format attibutenam

  • Material Type Views

    Hello Gurus,                   I know that the views in the Material master can be controlled through the material type settings. I would want to know if there is a setting to control users from viewing a specific view in the material master. Like th