For update in join

Hi.
I have a cursor that's going to be open for update ( for concurrent processing ) of some fields and do another things. The cursor will loop in a "for r_xpto in c_xpto loop" bases.
What's happening is that the exclusiveness is not being guaranteed. Here's the example code:
declare
cursor
C_joinUpdate
is
select T1.A, T2.B
from tableA T1, tableB T2
where T1.pk = t2.pk
for update of T1.B, T1.C;
begin
for R_Join in C_JoinUpdate loop
-- why multiple process can enter here simultaneously for the same T1 record???
-- something wrong with the "update of" or "for...loop" clauses?!?
end loop;
commit;
end;
Thanks in advance!
Rui Rodrigues

I don't see any exclusivenes, and the odd situation happens when multiple processes ( 2 in my simulation...) try to execute in the same instance! Since the for...loop hides an implicit cursor/open/fetch, does this statement takes more time to process than the time need to find out what rows to lock?!?!

Similar Messages

  • Oracle Syntax for Update with Join

    Can anyone help with the Oracle Syntax on and update that includes a join?
    This is what I've got:
    Update
    (SELECT a.DOCUMENT_NO
    From DOCUMENT_CONTROL a, DOCNOTEST b
    where a.DOCUMENT_NO = b.DOCUMENT_NO)
    set a.PATH = NULL
    Everything I try leads to another error message. With the current code I'm getting the error message: ORA-00971 a.path invalid identifier.
    I am much more familiar with SQL Server (if you can't tell :) This is the way I would write the above in SQL Server.
    UPDATE DOCUMENT_CONTROL
    Set [Path] = ''
    FROM DOCUMENT_CONTROL
    INNER JOIN DOCNOTEST
    ON DOCUMENT_CONTROL.DOCUMENT_NO=DOCNOTEST.DOCUMENT_NO
    where DOCUMENT_CONTROL.DOCUMENT_NO=DOCNOTEST.DOCUMENT_NO
    Does anyone have any advice for me? Thanks in advance

    Alternate syntax since it seems you're not able to update the join...
    update DOCUMENT_CONTROL a
    set
       a.path = null
    where a.path is not null
    and exists
       select null
       from DOCNOTEST b
       where  a.DOCUMENT_NO = b.DOCUMENT_NO
    );

  • VPD problem: select for update on join tables with policy on ref table

    In our application we use VPD. Now we ran into an issue. I will try to explain with EMP and DEPT table.
    EMP table has no VPD attached.
    DEPT table has VPD policy that forbids all updates, but allows select. (Policy returns '1=2' for statement type update.
    This query returns no rows:
    select * from emp join dept using (department_id) for update. This makes sense, because I'm going to update both the tables.
    However:
    select * from emp join dept using (department_id) for update of employee_id also returns no rows. THIS IS WRONG. I'm not going to update dept table.
    Any experience with this. Is this a known limitation ?

    I can see all the rows, because there is no select policy.
    However the point is, that VPD should allow me to update the emp table, because there is no update policy.
    With the 'for update of employee_id' clause, VPD should recognize that I'm not going to update the dept table, but only the emp table. But VPD does not recognize this, but applies the update policy of dept to the statement, making the statement to update no rows.
    (Reason behind my question is ADF Business Components, where you have ViewObjects with Referenced Entities. ADF BC generates this type of statement and now we run into this VDP limitation)

  • Difference in select for update of - in Oracle Database 10g and 11g

    Hi, I found out that Oracle Database 10g and 11g treat the following PL/SQL block differently (I am using scott schema for convenience):
    DECLARE
      v_ename bonus.ename%TYPE;
    BEGIN
      SELECT b.ename
        INTO v_ename
        FROM bonus b
        JOIN emp e ON b.ename = e.ename
        JOIN dept d ON d.deptno = e.deptno
       WHERE b.ename = 'Scott'
         FOR UPDATE OF b.ename;
    END;
    /While in 10g (10.2) this code ends successfully (well NO_DATA_FOUND exception is raised but that is expected), in 11g (11.2) it raises exception "column ambiguously defined". And that is definitely not expected. It seems like it does not take into account table alias because I found out that when I change the column in FOR UPDATE OF e.empno (also does not work) to e.mgr (which is unique) it starts working. So is this some error in 11g? Any thoughts?
    Edited by: Libor Nenadál on 29.4.2010 21:46
    It seems that my question was answered here - http://stackoverflow.com/questions/2736426/difference-in-select-for-update-of-in-oracle-database-10g-and-11g

    The behaviour seems like it really is a bug and can be avoided using non-ANSI syntax. (It makes me wonder why Oracle maintains two query languages while dumb me thinks that this is just a preprocessor matter and query engine could be the same).

  • Lock Cascade With Select for UPDATE

    If I had a employee table and a phone table with a parent/child relationship and a primary key constraint on the employee table-will issuing a select for update on the employee also lock the corresponding child rows on the phone table ?
    If not how can I bring this about ?

    You only need two sessions:
    First session: Issue the 'select for update'
    statements for the row(s) in both tables, don't
    rollback or commit
    Second session: try to update a row that you tried to
    lock in the first session (with NOWAIT).
    Thanks. I can try this definitely. A basic question.
    You are asking me to do a join on both the tables right ?
    Not two individual SQL statements ?
    Updating the primary key is known as a Bad Idea (tm).
    The key should never be touched because it should be
    meaningless. When you have a column that holds 'real'
    information it is no candidate for a primary key.
    Rgds,
    GuidoYes I am aware of that. I was just wondering what is the meaning behind this statement from this link ?
    http://www.akadia.com/services/ora_locks_survival_guide.html
    And the exact phrase from that link under the section Referential Integrity Locks (RI Locks)
    "RI constraints are validated by the database via a simple SELECT from the dependent (parent) table in question-very simple, very straightforward. If a row is deleted or a primary key is modified within the parent table, all associated child tables need to be scanned to make sure no orphaned records will result. "
    Thanks again.

  • 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.

  • Windows Update failed to check for updates with error 0x800B0001

    Hi all,
    I have a WSUS installed on a Windows Server 2008 R2 box, I have a new Windows Server 2012 box (joined to domain) that cannot get updates from the WSUS, whenever I try to search for new updates I receive the following error in event viewer:
    Windows Update failed to check for updates with error 0x800B0001
    Note: I cannot see the Win2K12 server in the WSUS console under computers node.

    I couldn't get it to run even after installing the mentioned KB fixes. So I investigated the error myself, and found a "hack" that seems to fix the issue. Wrote up a small piece on it here:
    http://tplive.azurewebsites.net/2013/12/windows-update-error/
    You and about a thousand other people have reported "I had already installed [the update], but installing it AGAIN fixed the problem.", which is almost assuredly a simple indication that the original installation of the update failed, and you simply did
    not recognize that the installation of the update was not successful.
    The fact that the /selfupdate folder was corrupted (read: missing files) pretty much says it all. There's no bug. Your installation of the update simply failed. (Or, the server wasn't healthy to begin with and you got what you got.)
    Bottom line: The only known cause for a client-side 0x800B0001 error code is that the WSUS server has not been
    properly and completely patched.
    Lawrence Garvin, M.S., MCITP:EA, MCDBA, MCSA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2013)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence R Garvin
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • Change control process for updating the UPK topics

    Is anyone using a change control process for updating the UPK topics for JD Edwards EnterpriseOne?
    With publishing the whole module and everything linked, I am finding it difficult if a developer is updating a topic and maybe in the middle of it, but has it checked in to the server?
    I would like to hear what others may be doing to control this.
    Thank you,
    Linda Paar
    MOM Brands

    Hello,
    If you have not already joined the UPK community in My Oracle Support, I would recommend you ask your question in that forum as there is a lot of experience there. Additional information can be found in the announcement at the top of this forum: https://forums.oracle.com/forums/ann.jspa?annID=1175
    Best regards,
    Marc

  • Clarification on SELECT for UPDATE

    HI All,
    I am doing a SELECT FOR UPDATE using NOWAIT as well as SKIPLOCKED option. I have question regarding the general behavior.
    Suppose let say , I have two tables (table1 and table 2 ).
    TABLE 1
    header_id NUMBER,
    service_id NUMBER
    TABLE 2
    header_id NUMBER,
    line_id NUMBER,
    status VARCHAR2
    And I run the following query
    SELECT t2.header_id, t2.line_id
    FROM table1 t1, table2 t2
    WHERE t1.header_id = t2.header_id
    AND t1.service_id = 1
    AND t2.status = 'SUCCESS'
    FOR UPDATE OF t2.status NOWAIT SKIP LOCKED;
    Questions
    1) Does adding both the NOWAIT and SKIP LOCKED in the sql help or just SKIP LOCKED would do fine.
    2) Lets say this SQL is executed when there are no rows with status as 'SUCCESS' in table2. Would this cause any performance impact. Like for example since its joining with table1 with table 2 based on the header id .Would it lock any rows on table1?
    ( My understanding was that it would not lock any row until it finds out any row with status as 'SUCCESS' but getting some conflicting answers)
    Thanks,
    Vj

    AKVK wrote:
    ( My understanding was that it would not lock any row until it finds out any row with status as 'SUCCESS' but getting some conflicting answers)THis would be my understanding too.
    To be sure make a test.
    Do the select for update so that it does not lock any rows.
    Then check the data dictionary select * from v$lock; to see for your session if there are any locks.

  • For update issue

    I got a scenario in which i update ecc by pulling data from database.
    For that i am using a BPM.
    while pulling data, i got a select with join to get data from couple of tables...Then immediately i update the selected rows by changing flags to show rows are selected.
    But before update triggers, my database is added with couple of new records. So delay makes to updated newly added records too.
    So basically i update unselected records.
    If i can use for update in select, i can slove this issue.
    But select is a join sql, so i can't use for update.
    How can i solve this issue?.

    Hi,
    Which adapter are you using Sender or Receiver?
    From you question, I think a Receiver, but still not sure.
    Anyways, coming to the question, in your Sender / Receiver JDBC adapter , select Adavanced Mode and under Transaction Isolation Level , Select Repeatbale Read or Serializable. This will solve your problem.
    <i>Transaction Isolation Level
    There are different levels of database transactions known as isolation levels. The isolation level determines how transactions running in parallel can influence each other. The options correspond to the JDBC constants:
    &#9679;     Default (default setting of the respective database)
    &#9679;     None
    &#9679;     read_uncommitted (weakest setting)
    &#9679;     read_committed
    &#9679;     repeatable_read
    &#9679;     serializable (strongest setting)</i>
    http://help.sap.com/saphelp_nw2004s/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    Regards
    Bhavesh

  • Update Query Joining Two Tables

    What is the sql for updating a table with another table's field value. I accomplished this using a subquery, but the query took forever to run. I was hoping there was a way to accomplish this inner join more efficiently.

    One way:
    UPDATE TABLEA A
    SET (COLUMNA, COLUMNB) = (SELECT COLUMNA, COLUMNB FROM TABLEB B WHERE (A.KEYCOLUMN1 = B.KEYCOLUMN1)
    WHERE EXISTS (SELECT 'X' FROM TABLEB B WHERE A.KEYCOLUMN1 = B.KEYCOLUMN1);
    1. The subquery should join on columns that are indexed. Use EXPLAIN PLAN to look at your query to determine if indexes are being used.
    2. The last WHERE clause ensures that you are only updating rows in TABLEA that have data in TABLEB. Without this clause COLUMNA and COLUMNB will be set to NULL if the subquery returns no rows; this will destroy any existing values in these columns.
    3. The "SELECT 'X'" in the last WHERE clause (rather than "SELECT (1)" or "SELECT *") tells Oracle that no data needs to be retrieved into buffers but that only the condition needs to be examined.
    Good luck!
    null

  • Blackberry Z10 - Stuck on Checking for update

    I recently bought a blackberry z10, and decided to update it before starting to use it which i regret now.
    Since then i have not been able to access the phone as it always comes back to the screen "Checking for updates".
    How long does this usually take as its been over 20 minutes and still on the same screen. I tried restarting the phone iseveral times s but i continue to get the same outcome when i turn the phone back on.
    any help would be appreciated.

    steveajcole wrote:
    I have powered off the devivce, removed the battery, left the device a part for hours. I put the device battery back in, power up the device, see the BlackBerry logo, then 'checking for updates' resumes and never stops. The phone is totally unusable. One thing I should mention is that the phone has no SIM inserted. Would this make a difference? 
    Leave it powered ON, as I stated above.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Error message: "playlists selected for updating no longer exist"

    I tried to update my ipod nano and I guess I had deleted a playlist, but since then, I have not been able to update. Every time I try, I get the following message:
    "Cannot be updated because all of the playlists selected for updating no longer exist."
    I haven't been able to highlight which playlists are selected to begin with.
    I read through the manual and thought that maybe rebooting the whole system might work. So I deleted Itunes from my computer and re-installed.
    Then I tried re-setting my ipod. So now I have nothing on my ipod.
    I also deleted everything from my library, thinking it might help to start from scratch. Nothing has worked.
    How do I "select" and "unselect" playlists so I can get up and running again?

    Here you go.
    http://discussions.apple.com/thread.jspa?messageID=607312&#607312

  • Why does my app store use a different account for downloading and another for updating apps?

    My app store used my own account for downloading and my sister's for updating, and it keeps telling me to reset my account. I already did that the other few times it told me to do that!

    Have you restored your device from your sister's backup?

  • Lost music on ipod because "playlists selected for updating no longer exist

    Not sure what I've done. I recently downloaded newer version of itunes. Then when synching, I had too much music in my library for the ipod to handle so it told me about doing the smart playlist. I erased a couple of playlists on the itunes menu I no longer wanted and then when I went to synch, this error came up "songs on the ipod cannot be updated because all of the playlists selected for updating no longer exist."
    Please help.....

    Check this out.
    iPod cannot sync because one or more playlist....

Maybe you are looking for