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.

Similar Messages

  • 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

  • HT3939 I got a new computer and need to down load the desktop application to be able to plug my Iphone into for updates. where can I go to get this application?

    I got a new computer and need to down load the desktop application to be able to plug my Iphone into for updates. where can I go to get this application?

    Click Itunes at the top of this page and download itunes.

  • HT4623 My Ipod touch is saying it is up to date when i check for updates, Its currently at 5.1.1 and wont update. It's preventing use of certain apps. How can i get it to update to ios 6+ ?

    Can anybody help with my question above?

    If you're getting the message using the device's Software Update function, it's a third generation iPod touch and can't be updated past 5.1.1.
    If you're using iTunes on a computer, it's either as above or the version of iTunes being too old.
    (93209)

  • When is SELECT FOR UPDATE used

    DB version:10gR2
    Since another thread of mine on this subject didn't go well, i am starting another thread.
    When exactly is SELECT..FOR UPDATE statement used? With the exception of using SELECT...FOR UPDATE in CURSOR declaration, I've rarely seen SELECT ...FOR UPDATE being used explicitlyby PL/SQL gurus in our firm. Why didn't they use SELECT..FOR UPDATE(i mean a stand alone SELECT FOR UPDATE, <em>not as a part of Cursor</em>) to lock rows before UPDATE/DELETE/INSERT in their codes?
    Edited by: M.Everett on Oct 20, 2008 12:00 PM
    edited the initial post to let the users know that I am refering to a stand alone SELECT FOR UPDATE statement, not the part of a cursor

    M.Everett wrote:
    What i gather from various sources in the Internet:
    1. SELECT FOR UPDATE is used mainly on CURSORs and very rarely used as a stand alone statement (if this is not the case you would have seen SELECT FOR UPDATE statements before every UPDATEs and DELETEs in PL/SQL codes)
    2. Stand alone SELECT FOR UPDATEs are used mainly when dealing with CLOB, BLOB
    Am i right in making these conclusions?1. This is probably a fair assumption.
    2. Not really. SELECT FOR UPDATE is not a requirement when dealign with (C|B)LOBs.
    SELECT FOR UPDATE allows an easy form of reference when you come to update rows in a cursor loop (although cursor loops should be rarely used), because rather than having to include a where condition on key columns you can just refer to the CURRENT ROW. Obviously, the main reason for using SFUs is the locking and this can become a requirement in some business environments where a user "picks up" a record to deal with and other users will then not see that record in their list or be able to select it for themselves.
    ;)

  • Error occuring in SELECT statement FOR UPDATE when using WITH cluase

    Hi,
    Iam using oracle 11g version
    Iam having a query with fetch records for update insid with cluase as
    cursor c1 is
    With abc as (
    SELECT col1,col2 from table1, table2 where < condition>
    for update of <col1> skip locked
    select * from abc,table3 where <condition>
    union all
    select * from table4 where id not in (select * from abc)
    if i add "for update of <col1> skip locked" this cluase
    iam getting error ORA-00907: missing right parenthesis
    when i remove "for update of <col1> skip locked" the block is working fine..
    can i know why error is occuring i

    Hi, first of all, your placing of "for update" clause is wrong. It should be at the end like:
    With abc as (
    SELECT col1,col2 from table1, table2 where < condition>
    select * from abc,table3 where <condition>
    union all
    select * from table4 where id not in (select * from abc)
    for update of <col1> skip locked;Second, if you try to compile it with this syntax then you will get a new error.
    ORA-01786:     FOR UPDATE of this query expression is not allowed
    Cause:     An attempt was made to use a FOR UPDATE clause on the result of a set expression involving GROUP BY, DISTINCT, UNION, INTERSECT, or MINUS.
    Action:     Check the syntax, remove the FOR UPDATE clause, and retry the statement.So, you will not be successful with the union clause in your query.

  • 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

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

  • 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

  • Using two cursors, one for updating salary values in the emp table

    Using COPIES of the employee and department tables provided by Oracle or using similar taples that provide employee, salary, job and dept in one table and dept number and department name in another table, write the following program. Use the dept table to step through sequentially and bring up the records with the same department from the employee table. Using an IF statement calcuate a new salary based on the job (you decide on the criteria). Update each record on the employee file (this is why you should use copies) with the new salary. In addition, calculate the total salary for each department and create a new table with the department number, the department name and the salary.
    I'm able to update the salary values, but I'm not sure how to insert those updated values into an empty table the way this problem is asking me to.
    Here's my script so far: any help would be greatly appreciated: )
    declare
    v_deptno emp.deptno%type;
    v_job emp.job%type;
    v_sal emp.sal%type;
    v_dname dept.dname%type;
    v_deptsal totalsal.deptsal%type;
    cursor salup_c is
    select job,sal
    from emp,dept
    where emp.deptno = dept.deptno
    for update of sal;
    cursor totdeptsal_c is
    select dname,sal
    from emp,dept
    where emp.deptno = dept.deptno;
    Begin
    open salup_c;
    loop
    fetch salup_c into v_job,v_sal;
    exit when salup_c%notfound;
    if v_job = 'CLERK' then
    v_sal := v_sal + 10;
    else
    if v_job = 'ANALYST' then
    v_sal := v_sal + 20;
    else
    if v_job = 'MANAGER' then
    v_sal := v_sal + 30;
    else
    if v_job = 'PRESIDENT' then
    v_sal := v_sal + 40;
    else v_sal := v_sal + 50;
    end if;
    end if;
    end if;
    end if;
    update emp
    set sal = v_sal
    where current of salup_c;
    open totdeptsal_c;
    v_deptsal := 0;
    loop
    fetch totdeptsal_c into v_dname, v_deptsal;
    exit when totdeptsal_c%notfound;
    v_deptsal := v_deptsal + v_sal;
    insert into totalsal
    values(v_deptno,v_dname,v_deptsal);
    end loop;
    close totdeptsal_c;
    end loop;
    close salup_c;
    end;
    /

    The script is actually inserting some values into the new table but look at what I'm getting
    Here it is: i only want the dept number ,the dept name, and total salary for each department.
    SQL> @ sndprob;
    PL/SQL procedure successfully completed.
    SQL> select * from totalsal;
    DEPTNO DNAME DEPTSAL
    RESEARCH 1620
    SALES 2410
    SALES 2060
    RESEARCH 3785
    SALES 2060
    SALES 3660
    ACCOUNTING 3260
    RESEARCH 3810
    ACCOUNTING 5810
    SALES 2310
    RESEARCH 1910
    DEPTNO DNAME DEPTSAL
    SALES 1760
    RESEARCH 3810
    ACCOUNTING 2110
    RESEARCH 2460
    SALES 3300
    SALES 2900
    RESEARCH 4625
    SALES 2900
    SALES 4500
    ACCOUNTING 4100
    RESEARCH 4650
    DEPTNO DNAME DEPTSAL
    ACCOUNTING 6650
    SALES 3150
    RESEARCH 2750
    SALES 2600
    RESEARCH 4650
    ACCOUNTING 2950
    RESEARCH 2110
    SALES 2950
    SALES 2600
    RESEARCH 4275
    SALES 2550
    DEPTNO DNAME DEPTSAL
    SALES 4150
    ACCOUNTING 3750
    RESEARCH 4300
    ACCOUNTING 6300
    SALES 2800
    RESEARCH 2400
    SALES 2250
    RESEARCH 4300
    ACCOUNTING 2600
    RESEARCH 3815
    SALES 4655
    DEPTNO DNAME DEPTSAL
    SALES 4305
    RESEARCH 6010
    SALES 4255
    SALES 5855
    ACCOUNTING 5455
    RESEARCH 6005
    ACCOUNTING 8005
    SALES 4505
    RESEARCH 4105
    SALES 3955
    RESEARCH 6005
    DEPTNO DNAME DEPTSAL
    ACCOUNTING 4305
    RESEARCH 2110
    SALES 2950
    SALES 2600
    RESEARCH 4305
    SALES 2600
    SALES 4150
    ACCOUNTING 3750
    RESEARCH 4300
    ACCOUNTING 6300
    SALES 2800
    DEPTNO DNAME DEPTSAL
    RESEARCH 2400
    SALES 2250
    RESEARCH 4300
    ACCOUNTING 2600
    RESEARCH 3690
    SALES 4530
    SALES 4180
    RESEARCH 5885
    SALES 4180
    SALES 5760
    ACCOUNTING 5330
    DEPTNO DNAME DEPTSAL
    RESEARCH 5880
    ACCOUNTING 7880
    SALES 4380
    RESEARCH 3980
    SALES 3830
    RESEARCH 5880
    ACCOUNTING 4180
    RESEARCH 3290
    SALES 4130
    SALES 3780
    RESEARCH 5485
    DEPTNO DNAME DEPTSAL
    SALES 3780
    SALES 5360
    ACCOUNTING 4960
    RESEARCH 5480
    ACCOUNTING 7480
    SALES 3980
    RESEARCH 3580
    SALES 3430
    RESEARCH 5480
    ACCOUNTING 3780
    RESEARCH 3830
    DEPTNO DNAME DEPTSAL
    SALES 4670
    SALES 4320
    RESEARCH 6025
    SALES 4320
    SALES 5900
    ACCOUNTING 5500
    RESEARCH 6040
    ACCOUNTING 8020
    SALES 4520
    RESEARCH 4120
    SALES 3970
    DEPTNO DNAME DEPTSAL
    RESEARCH 6020
    ACCOUNTING 4320
    RESEARCH 5850
    SALES 6690
    SALES 6340
    RESEARCH 8045
    SALES 6340
    SALES 7920
    ACCOUNTING 7520
    RESEARCH 8060
    ACCOUNTING 10080
    DEPTNO DNAME DEPTSAL
    SALES 6540
    RESEARCH 6140
    SALES 5990
    RESEARCH 8040
    ACCOUNTING 6340
    RESEARCH 2360
    SALES 3200
    SALES 2850
    RESEARCH 4555
    SALES 2850
    SALES 4430
    DEPTNO DNAME DEPTSAL
    ACCOUNTING 4030
    RESEARCH 4570
    ACCOUNTING 6590
    SALES 3100
    RESEARCH 2650
    SALES 2500
    RESEARCH 4550
    ACCOUNTING 2850
    RESEARCH 1920
    SALES 2760
    SALES 2410
    DEPTNO DNAME DEPTSAL
    RESEARCH 4115
    SALES 2410
    SALES 3990
    ACCOUNTING 3590
    RESEARCH 4130
    ACCOUNTING 6150
    SALES 2660
    RESEARCH 2220
    SALES 2060
    RESEARCH 4110
    ACCOUNTING 2410
    DEPTNO DNAME DEPTSAL
    RESEARCH 1770
    SALES 2610
    SALES 2260
    RESEARCH 3965
    SALES 2260
    SALES 3840
    ACCOUNTING 3440
    RESEARCH 3980
    ACCOUNTING 6000
    SALES 2510
    RESEARCH 2070
    DEPTNO DNAME DEPTSAL
    SALES 1920
    RESEARCH 3960
    ACCOUNTING 2260
    RESEARCH 3830
    SALES 4670
    SALES 4320
    RESEARCH 6025
    SALES 4320
    SALES 5900
    ACCOUNTING 5500
    RESEARCH 6040
    DEPTNO DNAME DEPTSAL
    ACCOUNTING 8060
    SALES 4570
    RESEARCH 4130
    SALES 3980
    RESEARCH 6040
    ACCOUNTING 4320
    RESEARCH 2120
    SALES 2960
    SALES 2610
    RESEARCH 4315
    SALES 2610
    DEPTNO DNAME DEPTSAL
    SALES 4190
    ACCOUNTING 3790
    RESEARCH 4330
    ACCOUNTING 6350
    SALES 2860
    RESEARCH 2420
    SALES 2270
    RESEARCH 4330
    ACCOUNTING 2620
    196 rows selected.

  • How to update data when primary key is set through for update cursor

    Dear friends,
    I have tried to update data in the table through forms using cursor for update and i have given the plsql i have used please help me where i do mistake.
    DECLARE CURSOR EMP IS
    SELECT EMPNO,EMPNAME,FATHERNAME,COMMUNITY,SEX,BILLUNIT,BIRTHDATE,RLYJOINDATE,RETIREMENTDATE
    FROM PRMAEMP WHERE BILLUNIT=:CTRL.BILLUNIT AND SERVICESTATUS='SR'ORDER BY DESIGCODE,SCALECODE
    FOR UPDATE;
    BEGIN
    GO_BLOCK('EMP_DETAILS');
    SYNCHRONIZE;
    FOR I IN EMP
    LOOP
    I.BILLUNIT:=:EMP_DETAILS.BILLUNIT;     
    I.EMPNO:=:EMPNO;
    I.EMPNAME:=:EMPNAME;
    I.FATHERNAME:=:FATHERNAME;
    I.COMMUNITY:=:COMMUNITY;
    I.SEX:=:SEX;
    I.BIRTHDATE:=:BIRTHDATE;
    I.RLYJOINDATE:=:RLYJOINDATE;
    I.RETIREMENTDATE:=:RETIREMENTDATE;
    DOWN;
    END LOOP;
    COMMIT;
    END;
    your help is needed immediately

    DECLARE CURSOR ABC IS
       SELECT EMPNO,
              EMPNAME,
              FATHERNAME,
              COMMUNITY,
              SEX,
              BILLUNIT,
              BIRTHDATE,
              RLYJOINDATE,
              RETIREMENTDATE
    FROM PRMAEMP
    WHERE BILLUNIT=:CTRL.BILLUNIT
    AND SERVICESTATUS='SR'
    ORDER BY DESIGCODE,SCALECODE
    FOR UPDATE OF COMMUNITY;
    V_EMPNO           PRMAEMP.EMPNO%TYPE;
    V_EMPNAME         PRMAEMP.EMPNAME%TYPE;
    V_FATHERNAME      PRMAEMP.FATHERNAME%TYPE;
    V_COMMUNITY       PRMAEMP.COMMUNITY%TYPE;
    V_SEX             PRMAEMP.SEX%TYPE;
    V_BILLUNIT        PRMAEMP.BILLUNIT%TYPE;
    V_BIRTHDATE       PRMAEMP.BIRTHDATE%TYPE;
    V_RLYJOINDATE     PRMAEMP.RLYJOINDATE%TYPE;
    V_RETIREMENTDATE  PRMAEMP.RETIREMENTDATE%TYPE;
    BEGIN
       GO_BLOCK('EMP');
       SYNCHRONIZE;
       OPEN ABC;
       LOOP
          FETCH ABC INTO .... /*yOU NEED TO MENTION YOUR VARIABLES HERE*/;
          UPDATE PRMAEMP
          SET BILLUNIT= :EMP.BILLUNIT,
              EMPNO= :EMPNO,
              EMPNAME= :EMPNAME,
              FATHERNAME= :FATHERNAME,
              COMMUNITY= :COMMUNITY,
              SEX= :SEX,
              BIRTHDATE= :BIRTHDATE,
              RLYJOINDATE= :RLYJOINDATE,
              RETIREMENTDATE= :RETIREMENTDATE
          WHERE CURRENT OF ABC;
          EXIT WHEN ABC%NOTFOUND;
       END LOOP;
       CLOSE ABC;
    END;
    COMMIT;
    END;Cheers
    Sarma.

  • FOR UPDATE cursor is causing Blocking/ Dead Locking issues

    Hi,
    I am facing one of the complex issues regarding blocking / dead locking issues. Please find below the details and help / suggest me the best approach to ahead with that.
    Its core Investment Banking Domain, in Our Day to day Business we are using many transaction table for processing trades and placing the order. In specific there are two main transaction table
    1)     Transaction table 1
    2)     Transaction table 2
    These both the tables are having huge amount of data. In one of our application to maintain data integrity (During this process we do not want other users to change these rows), we have placed SELECT …………….. FOR UPDATE CURSOR on these two table and we have locked all the rows during the process. And we have batch jobs (shell scripts ) , calling this procedure , we will be running 9 times per day 1 hrs each start at 7:15AM in the morn finish it up in the eve 5PM . Let’s say. The reason we run the same procedure multiple times is, our business wants to know the voucher before its finalized. Because there is a possibility that order can be placed and will be updated/cancelled several times in a single day. So at the end of the day , we will be sending the finalized update to our client.
    20 07 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 08 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 09 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 10 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 11 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 12 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 13 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 14 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 15 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 16 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 17 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    Current Program will look like:
    App_Prc_1
    BEGIN
    /***** taking the order details (source) and will be populate into the table ****/
    CURSOR Cursor_Upload IS
    SELECT col1, col2 … FROM Transaction table1 t 1, Source table 1 s
    WHERE t1.id_no = t2.id_no
    AND t1.id_flag = ‘N’
    FOR UPDATE OF t1.id_flag;
    /************* used for inserting the another entry , if theres any updates happened on the source table , for the records inserted using 1st cursor. **************/
    CURSOR cursor_update IS
    SELECT col1, col2 … FROM transaction table2 t2 , transaction table t1
    WHERE t1.id_no = t2.id_no
    AND t1.id_flag = ‘Y’
    AND t1.DML_ACTION = ‘U’,’D’ -- will retrieve the records which are updated and deleted recently for the inserted records in transaction table 1 for that particular INSERT..
    FOR UPDATE OF t1.id_no,t1.id_flag;
    BLOCK 1
    BEGIN
    FOR v_upload IN Cursor_Upload;
    LOOP
    INSERT INTO transaction table2 ( id_no , dml_action , …. ) VALUES (v_upload.id_no , ‘I’ , … ) RETURNING v_upload.id_no INTO v_no -- I specify for INSERT
    /********* Updating the Flag in the source table after the population ( N into Y ) N  order is not placed yet , Y  order is processed first time )
    UPDATE transaction table1
    SET id_FLAG = ‘Y’
    WHERE id_no = v_no;
    END LOOP;
    EXCEPTION WHEN OTHER THEN
    DBMS_OUTPUT.PUT_LINE( );
    END ;
    BLOCK 2
    BEGIN -- block 2 starts
    FOR v_update IN Cursor_Update;
    LOOP;
    INSERT INTO transaction table2 ( id_no ,id_prev_no, dml_action , …. ) VALUES (v_id_seq_no, v_upload.id_no ,, … ) RETURNING v_upload.id_no INTO v_no
    UPDATE transaction table1
    SET id_FLAG = ‘Y’
    WHERE id_no = v_no;
    END LOOP;
    EXCEPTION WHEN OTHER THEN
    DBMS_OUTPUT.PUT_LINE( );
    END; -- block2 end
    END app_proc; -- Main block end
    Sample output in Transaction table1 :
    Id_no | Tax_amt | re_emburse_amt | Activ_DT | Id_Flag | DML_ACTION
    01 1,835 4300 12/JUN/2009 N I ( these DML Action will be triggered when ever if theres in any DML operation occurs in this table )
    02 1,675 3300 12/JUN/2009 Y U
    03 4475 6500 12/JUN/2009 N D
    Sample output in Transaction table2 :
    Id_no | Prev_id_no Tax_amt | re_emburse_amt | Activ_DT
    001 01 1,835 4300 12/JUN/2009 11:34 AM ( 2nd cursor will populate this value , bcoz there s an update happened for the below records , this is 2nd voucher
    01 0 1,235 6300 12/JUN/2009 09:15 AM ( 1st cursor will populate this record when job run first time )
    02 0 1,675 3300 12/JUN/2009 8:15AM
    003 03 4475 6500 12/JUN/2009 11:30 AM
    03 0 1,235 4300 12/JUN/2009 10:30 AM
    Now the issues is :
    When these Process runs, our other application jobs failing, because it also uses these main 2 tranaction table. So dead lock is detecting in these applications.
    Solutin Needed :
    Can anyone suggest me , like how can rectify this blocking /Locking / Dead lock issues. I wants my other application also will use this tables during these process.
    Regards,
    Maran

    hmmm.... this leads to a warning:
    SQL> ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL';
    Session altered.
    CREATE OR REPLACE PROCEDURE MYPROCEDURE
    AS
       MYCOL VARCHAR(10);
    BEGIN
       SELECT col2
       INTO MYCOL
       FROM MYTABLE
       WHERE col1 = 'ORACLE';
    EXCEPTION
       WHEN PIERRE THEN
          NULL;
    END;
    SP2-0804: Procedure created with compilation warnings
    SQL> show errors
    Errors for PROCEDURE MYPROCEDURE:
    LINE/COL                                                                          ERROR
         12/9        PLW-06009: procedure “MYPROCEDURE” PIERRE handler does not end in RAISE or RAISE_APPLICATION_ERROR
         :)

  • For Update Cursor

    Hi ,
    Can you let me know what happen in this cursoe when we use for update?
    CURSOR TRAN_CUR
    IS
    SELECT TRANSACTION_ID
    ,YEAR_MONTH_DT
    ,SOURCE_CD
    ,INVOICE
    FROM
    TRANSACTION_CONTROL
    WHERE
    NEXT_PROCESS = 'MAP'
    FOR
    UPDATE;
    Thanks in advance,

    Assuming that the cursor is written correctly SQL will lock each row as it is selected. The lock will remain until you do a COMMIT or a ROLLBACK. Normally Oracle will lock rows when you perform DML on them but FOR UPDATE causes the row to be locked when the select occurs.
    FOR UPDATE also has the happy side effect of allowing use of the CURRENT OF predicate in select loops simplifying where clauses; when you say "WHERE CURRENT OF cursor_name" for a FOR UPDATE cursor you will only operate on the current row.
    Now for the unhappy side effects. FOR UPDATE cursors run more slowly than normal cursors because it takes time and effort to lock the rows. Second (and worse) you are locked into one transaction for the entire cursor execution because performing a SELECT after a commit or rollback results in the FETCH OUT OF SEQUENCE error (this is not usually a problem but could result in running out of rollback segments or undo space for newer databases. Its unlikely these days but can happen). Finally, performing DML in one statement (as in insert into/select from) is often faster than performing the select loops with DML inside them anyway.
    I wouldn't use FOR UPDATE unless I really needed the rows locked because of the performance hit.

  • For Update In Cursor

    cursor t_c is
    select a.f1, b.f2, c.f3
    from A, B, C
    where A.id = B.id
    and A.id = C.id
    for update B.f5, B.f6, B.f7, C.f8, C.f9;
    for item in t_c
    loop
    update B
    set f5 = something,
    f6 = something,
    f7 = something;
    where current of t_c;
    update C
    set f8 = something,
    f9 = something;
    where current of t_c;
    end loop;
    my selection statement is fine.
    but the update statement is not working, as i end
    up with the original values.
    when i take out the update statement for table C
    (including the 'for update' section), the update
    for table B works fine.
    i can't see any mistakes from my script.
    could anyone please point out?
    thanks ...

    have you tried to rewrite the cursor to not use a for update of,
    but to use the rownum instead?
    cursor t_c is
    select a.f1, b.f2, c.f3
    from A, B, C
    where A.id = B.id
    and A.id = C.id
    for update B.f5, B.f6, B.f7, C.f8, C.f9;
    for item in t_c
    loop
    update B
    set f5 = something,
    f6 = something,
    f7 = something;
    where current of t_c;
    update C
    set f8 = something,
    f9 = something;
    where current of t_c;
    end loop;
    my selection statement is fine.
    but the update statement is not working, as i end
    up with the original values.
    when i take out the update statement for table C
    (including the 'for update' section), the update
    for table B works fine.
    i can't see any mistakes from my script.
    could anyone please point out?
    thanks ...

Maybe you are looking for

  • TV video sync???

    I have a couple of episodes of a tv show that I purchased from iTunes. They are in the TV library, checked off, but don't sync to my new ipod 8G nano. What am I missing here? Thanks, Rita

  • Regarding message flow in sap xi

    HI i want to the flow of message from outbound system to inbound system completly. ie  i want to know ---which components like message interfaces,rd,id,sa,ra,.............such types.i want to know  the complete flow and after which step which is to b

  • The MDM repository is in read-only mode

    Hi Experts, In our environment we have a Master ans Slave repository and the synchronization is being scheduled daily. Now we understand from the MDIS logs of the Master repository that the repository is in Read-Only mode and none of the records can

  • Messed up icons 3GS

    I spoke to a nice woman in Apple Support. They apparently have no fix for the messed up icon problem, meaning icons and apps don't match. Has anyone figured out their own fix?

  • How to make sure everything is saved?

    I'm about to format my computer... the entire C drive.. and reinstall windows... on the C:Drive is my Premiere Pro. .I have CS3.. I wish to reinstall it after the format.. but.. it would be a catastrophe to me if my current projects were to be delete