For Update Of &Where current of

Can you please give answer anyone,What is main use of For update Clause and Where current of Clause?

When you will want to lock a set of records even before you change them in your program. Oracle offers the FOR UPDATE clause of the SELECT statement to perform this locking.
When you issue a SELECT...FOR UPDATE statement, the RDBMS automatically obtains exclusive row-level locks on all the rows identified by the SELECT statement, holding the records "for your changes only" as you move through the rows retrieved by the cursor. No one else will be able to change any of these records until you perform a ROLLBACK or a COMMIT.
The Where Current Of statement allows you to update or delete the record that was last fetched by the cursor.

Similar Messages

  • The Cursor's "For Update " and " Where Current of C1" Error in Form9i

    Hi,
    I use a cursor with for update statement. And after it, I update the table with "where current of", then it cause the forms hanged up. But In form50 of dp2k, I can run the form successfully.
    The following source code are written in a Key-Next-Item
    Please help me with the problem!!!!!
    declare
    v_cash date;
    v_entno varchar2(16);
    Cursor c1 is
    select proc_date,entno from loan_bank for update;
    begin
    open c1;
    loop
    fetch c1 into v_cash,v_entno;
    exit when c1%NOTFOUND;
    update loan_bank set proc_date=sysdate where current of c1;
    end loop;
    commit;
    close c1;
    show_alert_info('OK! Done to Proc Date');
    end;

    Hello there,
    I'm also facing the same problem...
    Have you found any solution or work-around yet?
    The code i'm using is the following:
    IS
    CURSOR cur_autonum
    IS
    SELECT an_nr + 1
    FROM autonum
    WHERE an_kode ='ADV'
    FOR UPDATE OF an_nr NOWAIT
    RECORD_NOT_FOUND EXCEPTION;
    RECORD_IS_LOCKED EXCEPTION;
    PRAGMA EXCEPTION_INIT(RECORD_IS_LOCKED,-54);
    BEGIN
    OPEN cur_autonum;
    FETCH cur_autonum INTO :ptperson.pe_nr;
    IF cur_autonum%FOUND
    THEN
    UPDATE autonum
    SET an_nr = :ptperson.pe_nr
    WHERE CURRENT OF cur_autonum;
    CLOSE cur_autonum;
    ELSE
         CLOSE cur_autonum;
         RAISE RECORD_NOT_FOUND;
    END IF;
    EXCEPTION
    WHEN RECORD_NOT_FOUND
    THEN
    :global.rc := fnc_alert(118);
    clear_record;
    previous_record;
    RAISE Form_Trigger_Failure;
    WHEN RECORD_IS_LOCKED
    THEN
    IF cur_autonum%ISOPEN
    THEN
    CLOSE cur_autonum;     
    END IF;
    :global.rc := fnc_alert(119);
    clear_record;
    previous_record;
    RAISE Form_Trigger_Failure;
    WHEN OTHERS
    THEN
    IF cur_autonum%ISOPEN
    THEN
    CLOSE cur_autonum;     
    END IF;
    RAISE;
    END;
    greetings,
    Emiel

  • For Update and Where Current Of -

    HI All,
    We have been using Select For Update statement with wait time (i.e in seconds) in various places inside our applications. This forces for locking those rows and we commit the work at the end of our work to ensure we release the locked rows to avoid deadlock in the application. However at times we face locks during heavy contention when running those cursors in the application.
    I have 2 questions here
    1) By using where current of do we stand to gain anything advantageous so that we gain out of it. Will it try to eliminate such row level locks said above.
    2) How to avoid locks occurring in the application while using Select For Update Statements
    Please share your thoughts and suggestions to overcome on this worrying/concerning topic.
    Thanks in advance

    ramarun wrote:
    HI All,
    We have been using Select For Update statement with wait time (i.e in seconds) in various places inside our applications. This forces for locking those rows and we commit the work at the end of our work to ensure we release the locked rows to avoid deadlock in the application. However at times we face locks during heavy contention when running those cursors in the application. FOR UPDATE exists to put locks on selected data so other processes cannot lock data between the time it is selected and processed. As you're finding there are disadvantages.
    1) By using where current of do we stand to gain anything advantageous so that we gain out of it. Will it try to eliminate such row level locks said above.WHERE CURRENT OF will save you typing when you do WHERE clauses. It should not affect locking at all
    2) How to avoid locks occurring in the application while using Select For Update Statements You don't avoid locks when using the FOR UPDATE clause because that is what its for. If you don't need to lock the data then do not use FOR UPDATE.
    Edited by: riedelme on Aug 11, 2010 5:34 AM
    Updated after sybrand's comments below. Technically using WHERE CURRENT OF shouldn't affect locking directly - rows will remain locked until the transaction is terminated. Referencing the data via the rowid will be more efficient and therefore shorten the time taken to process the transaction

  • Trying to reinstall Canon MX882 printer, I get the message /System/Library/Extensions/AppleUSBEthernetHost.kext installed improperly and cannot be used.Try reinstalling or contact vendor for update. Where is this and what do I do/

    Trying to reinstall MX882 Canon printer after upgrading to OSX Mavericks. Printer will not print and I get a message "The system extension "/System/Library/
    Extensions/AppleUSBEthernetHost.kext" was installed improperly and cannot be used. Try reinstalling it, or contact vendor for update."
    What do I do and where is this extension?

    beverly216 wrote:
    What do I do and where is this extension?
    I would recommend you download and install the OS X 10.9.5 Combo Update.
    That file is part of the operating system and it is located where the error shows, i.e. HD > System > Library > Extensions. It would seem that when you updated, this file and maybe others have not updated correctly. So running the Combo Update may help resolve this.

  • "Check for Updates" checks where?

    In the 10.1.3 Connector there is a "Check for Updates" button on the "About Oracle Connector for Outlook" window. I'm interested in configuring this and need to figure out a few things. What server or configuration control is there for this feature? Are there client side settings I need to push with the connector to point to a specific server or does this check a central server provided by Oracle? If so, can this be overridden? Are there any notes or docs available either on OTN or Metalink?
    thanks,
    Jason

    The proper way to distribute the latest WUA (.320) to the clients in a WSUS administered environment, is to update the WSUS server(s) with this update:
    An update to harden Windows Server Update Services
    then the clients WUA will be selfupdated when they connect to the WSUS server.
    Rolf Lidvall, Swedish Radio (Ltd)

  • HT4623 5.In the Summary pane, click Check for Update.  Where is this imaginary place?  Not on your website

    Tring to update from Itunes iphone 4 and not seeing anything resembling the above.  Only references to iphone 4s or 5..Don't see the summary pane at all...Help

    Make sure you have the latest iTunes (11.1.5)
    Connect the phone to your computer
    The iPhone's name will appear in iTunes. If you don't see it go to the View menu and check "Show Sidebar"
    Click on the iPhone's name
    The Summary pane will appear as if by magic

  • For update & where current of in cursor

    Hi,
    Please explain any For Update with WHERE CURRENT OF clause in cursor.
    Diwakar

    Hi,
    I am getting meaning of FOR UPDATE CLAUSE but Right now i am not getting WHERE CURRENT OFF clause.
    Basically For Update clause in PL/SQL cursor used for locking the Row which is extracted by the query. But what is the use of WERE CURRENT OF Clause. When we use WERE CURRENT OF clause at that time cursor must should have FOR UPDATE CLAUSE in cursor declaration.
    Thank you Diwakar
    Here is link in documentation:
    http://download-uk.oracle.com/docs/cd/B14117_01/server
    .101/b10759/statements_10002.htm#i2126016
    Peter D.
    It's link to SELECT FOR UPDATE statement.
    Message was edited by:
    Peter D.

  • Processing SELECT FOR UPDATE queries

    Hello,
    Is there any occi sample code that uses "SELECT ... FOR UPDATE" and "WHERE CURRENT OF"?

    I think "where current of" is not supported in OCI as well.
    But, may be I can use the below steps for positioned updates using "select for ... updat" sqls
    1. Lock the rows by executing the "select for ...update " SQL.
    2. Get the result set
    3. Now, as iterating the result set, get the current row id using ResultSet.getRowid() or getRowPosition() (I am not sure which one to use. But, I think getRowPosition() is suitable as it explicitly returns the rowid of the current row position)
    4. Execute the update stmt "update tableName set ... where rowid=?"
    5. Iterate the Result set and update the row as in pt. 4
    6. commit the transaction (this unlocks the rows)
    Please let me know if this is correct...

  • Checking for updates after System Restore

    After installing updates in September I had several problems, but system restore got things working again.  However, when I check for updates now the system appears to see the updates that were removed by system restore as if they are still installed or, as if they are available on the machine and therefore not needed.  I thought system update checked for updates based on current machine status.
    Would system restore typically leave updates on the machine such that an update check may see them as not needed?
    Is there a way to change settings or reset the update catalog to check for updates NOT currently installed?
    Thanks - John
    W520.  Win7 Pro 64.  i7-2860QM.  Quadro 1000M.  BIOS 1.38
    W530-2436CTO, i7-3840QM, K2000M, FHD 1920x1080, 32GB RAM, 256GB SSD.
    Others models: T40, W510, W520, X230.

    Hi,
    I have not delved deep enough to say which item actually holds the list of active Chats or Conversations in the side bar.
    The chat.db item itself is the one that hold the "history" that shows up when your start a chat with someone you have chatted to before in iMessages.
    You need to have Saved Chats  in the Archive folder for this to work with AIM, Jabber, Yahoo and Bonjour Buddies.
    Apple's own documentation tends to refer to iMessages as Conversations and any other account as Chats.
    The exception now being SMS/text which the app Links to iMessages.
    If you just Restore the whole computer to the last day you ran OS X 10.10.1 then it should have all the Chats/Conversations you were having that day.
    However changing them by effectively Importing the newer ones (those up to the last time you used OS X 10.10.3beta) will upset things.
    9:45 pm      Wednesday; March 25, 2015
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • List current DML in DB including SELECT for Update

    In order to list all currently opened DML we can select v$open_cursor and link it to to v$SQL in order to retrieve the v$SQL.COMMAND_TYPE.
    All DML operation have the following number in v$sql.command_type :
    2 : 'INSERT'
    6 : 'UPDATE',
    7 : 'DELETE',
    189 : 'MERGE'
    But 'SELECT for update it is still 3 like any non regular SELECT.
    I did not found information in v$lock nor in v$transaction that would allow me
    to link an open cursor of type 3 (SELECT but in fact for update) to the opened transaction in v$transaction.
    Does anybody knows how to assert than a SELECT is in fact a DML short of grepping the 'FOR update' in the SQL text.
    Such an Horrible trick would force me to search all opened cursor text for each session with an entry in v$transaction.

    Thanks for replying.
    I could have had the usage of less aggressivity and more competences. You advice is simply stupid :
    -- seesion 1 :
    select * from toto where id = 20 for update ;
    select sid from v$mystat where rownum = 1 ;   -- > sid=1614
    -- session control : check v$transaction
    col version new_value version noprint
    col field new_value field noprint
    col used_urec format 999999 head 'Undo|Records'
    col undo_size head 'Undo|size (k)' justify c
    set lines 150
    select substr(version,1,instr(version,'.',1)-1) version from v$instance;
    select decode(&version,9,'','XID,') field from dual;
    Select r.segment_name,To_Char(To_Date(vt.Start_Time,'MM-DD-RR HH24:MI:SS'),'MM-DD HH24:MI:SS') strt
         ,  decode(vs.status,'ACTIVE',vs.last_Call_et,0) since , vs.sid, vs.status se_status,
           &field vt.status tr_status, log_io, phy_io,cr_get,cr_change, vt.used_urec, vt.used_ublk * p.value/1024 undo_size
      From dba_rollback_segs dr,
           v$rollstat rs,
           v$transaction vt,
           v$session vs,
           v$process vp,
           dba_rollback_segs r,
           v$parameter p
      Where vs.Paddr = vp.Addr (+) AND p.name  = 'db_block_size'
       and vt.xidusn (+)  = r.segment_id
       And vs.UserName Is Not Null
       And vs.Taddr Is Not Null
       And vs.Taddr = vt.Addr
       And vt.xidusn = dr.segment_id
       And vt.xidusn = rs.usn
        Order By VS.OsUser, To_Date(vt.Start_Time,'MM-DD-RR HH24:MI:SS') ;
                                   Running        Session                   Transact                                                Undo    Undo
    SEGMENT_NAME Start time       time (s)    SID Status   XID              Status       LOG_IO     PHY_IO     CR_GET  CR_CHANGE Records  size (k)
    _SYSSMU21$   04-13 11:02:24          0   1614 INACTIVE 0015002A0003A800 ACTIVE            3          0        104          0       1          8
    -- so we have a transaction in 1614. Let's retrieve its SQL :
    -- session control : what do we have in  v$session :
      1  select sql_hash_value, b.sql_text sql_text, prev_hash_value , bb.sql_text prev_sql_text
      2    from
      3       v$session  a, v$sql b, v$sql bb
      4  where sid = 1614
      5    and a.sql_hash_value = b.hash_value (+)
      6*   and a.prev_hash_value = bb.hash_value (+)
    SQL> /
    SQL_HASH_VALUE SQL_TEXT                                      PREV_HASH_VALUE PREV_SQL_TEXT
                 0                                                     897388722 select sid from v$mystat where rownum = 1
    -- gone !
    -- Conclusion : joining v$session to v$transaction is useless if you want to retrieve the SQL in system currently opened.
    -- moreover, if  start a transaction with many queries, you are still limited to 2 slot in v$session.

  • ITunes "Check for Updates" says 7.3.1 is the most current version

    Hi all.
    We all know 7.3.2 is out. But when I go to "iTunes--->Check for Updates" in iTunes, it says 7.3.1 is the most current version. What gives?
    Thanks in advance.

    Also make sure that you don't move your Apple apps from their default location. If you do then the Software Updater doesn't know where to look to see what version that you currently have.
    MJ

  • Adobe creative cloud is asking for a serial number for updates - where do I get this from?

    Adobe Creative cloud is asking for a serial number for updates - where do I get this from
    we have recently Bought 5 x 1 year licences and been using this a month
    Michael

    Hi Mick,
    Please refer to the below link.
    http://helpx.adobe.com/creative-cloud/kb/ccm-prompt-serial-number.html
    Thanks

  • HT3576 Ok so i have this iPod touch (3rd gen) and i'm trying to update it through iTunes and when i click  check for update it keeps saying this version of iPod software (2.2.1) is your current version. what do i do? how do i update it?

    Ok so i have this iPod touch (3rd gen) and i'm trying to update it through iTunes and when i click  check for update it keeps saying this version of iPod software (2.2.1) is your current version. what do i do? how do i update it?

    You have a 1st generation iPod Touch. It can not be upgraded beyond iOS 3.1.3, it is available at the link below.
    http://support.apple.com/kb/HT2052

  • HT4623 I have plugged in my ipad to my computer and Itunes is up on my computer but where do I find these things in Itunes, # In iTunes, select your device.  # In the Summary pane, click Check for Update, to update my ipad?

    I have plugged in my ipad to my computer and Itunes is up on my computer but where do I find these things in Itunes, # In iTunes, select your device.  # In the Summary pane, click Check for Update, to update my ipad?

    Tap to enlarge.

  • I am updating iphoto 9.1 to 9.3 and every time when I clicked for update aps store asked to open it in the account where you purchased. I am using the same account and its available in the purchased item of this account. Can someone resolve this problem.

    I am updating iphoto 9.1 to 9.3 and every time when I clicked for update aps store asked to open it in the account where you purchased. I am using the same account and its available in the purchased item of this account. But in my purchased item library it indicates that you update iPhoto. I am not sure which account the aps store asking. Can someone resolve this problem.

    Contact App Store support. They're the folks who can help with Account issues.
    Regards
    TD

Maybe you are looking for

  • Could I have got a new power adapter for free?

    My power adapter for my mac stopped working recently and as far as I know I didn't cause any damage to it myself. I read the following on the apple website: Additional Information Whether your product is in or out of warranty, you can take your adapt

  • How is the best way to manage the stats table?

    Hello! I have the Integration 2.1 working with an Oracle 8.1.7 db. I noticed that the table STATS is growing pretty fast. How is the best way to manage this table?... I haven't found something related with this issue in the documentation, but at leas

  • Account of the opportunity is not populated after the creation of a task

    Hi, In our project, we are using the Opportunity Object after the creation of a task. Our tasks are always related to an existing account. I was wondering why when I create an opportunity from a task, the field "Account Name" is not populated by defa

  • How to send a group email and have the recipients hidden?

    How do I send a group email and have the recipients hidden?

  • STO deliveries

    In a STO with delivery scenario, I have a problem. VL10B for sales order should not consider stock in quality VL10B for purchase order STO (UB) should take stock in quality. So, for purchase orders, I defined a new checking rule "ZM" for the checking