Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate Multiple Rows in same table after Update using Trigger
    primarykey
    data
    text
    <p>If i update ACK or ReJ column it should update all the other columns with the same GlobalID.</p> <pre><code>create table t_emp( empid varchar2(10) not null, empname varchar2(50), Dep varchar2(50), ACk number(5), REJ number(5), globalID varchar2(10) default '0' ); insert into t_emp t values ( 'TM01' , 'Logu','Java',null,null,'01'); insert into t_emp t values ( 'BT01' , 'Logu','Java' ,null,null,'01'); insert into t_emp t values ( 'Oracle01' , 'Logu','DBA' ,null,null,'01'); insert into t_emp t values ( 'Google01' , 'Logu','Design' ,null,null,'0'); insert into t_emp t values ( 'AR02' , 'Uthaya','CRM' ,null,null,'02'); insert into t_emp t values ( 'RIL02' , 'Uthaya','Java' ,null,null,'02'); insert into t_emp t values ( 'EA02' , 'Uthaya','DBA' ,null,null,'02'); insert into t_emp t values ( 'TCS02' , 'Uthaya','Java' ,null,null,null); insert into t_emp t values ( 'P05' , 'Krish','.Net' ,null,null,'05'); insert into t_emp t values ( 'TCS06' , 'Krish','.Net' ,null,null,'06'); insert into t_emp t values ( 'IBM06' , 'Krish','.Net' ,null,null,'06'); CREATE OR REPLACE TRIGGER t_emp_update AFTER UPDATE ON t_emp FOR EACH ROW DECLARE t_Ack varchar2(15); t_Rej varchar2(15); t_globalID varchar2(10); t_empid varchar2(10); BEGIN t_globalID := :new.globalID; t_Ack := :new.ACk; t_Rej := :new.REJ; t_empid := :new.empid; IF t_Ack is not null then DBMS_OUTPUT.PUT_LINE('t_Ack := ' || t_Ack || ', t_globalID := '|| t_globalID ||', t_empid := '||t_empid); update t_emp set ACk = t_Ack where globalID = t_globalID and empid != t_empid; end if; IF t_Rej is not null then DBMS_OUTPUT.PUT_LINE('t_REJ := ' || t_Rej || ', t_globalID := '|| t_globalID ||', t_empid := '||t_empid); update t_emp set Rej = t_Rej where globalID = t_globalID and empid != t_empid; end if; END; update t_emp v set Rej = 1 where empid = 'TCS06'; </code></pre> <p>If I Update <code>empid = 'TCS06'</code> it should Update Internally all rows with same globalID (06).</p> <pre><code>select * from t_emp order by empname,globalID; </code></pre> <p>I am getting some errors in this trigger.</p> <pre><code>ORA-04091: table TEST1.T_EMP is mutating, trigger/function may not see it ORA-06512: at "TEST1.T_EMP_UPDATE", line 17 ORA-04088: error during execution of trigger 'TEST1.T_EMP_UPDATE' </code></pre> <p>Kindly Help me ...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload