Hi guys,
I am writing a trigger. The code is as under :-
table :- Emp_test
empno Number
ename Varchar2(25)
Crt_by Varchar2(25)
Cdate date
I am written a trigger on the above table
Create or replace trigger emp_trig before insert on emp_test for each row
declare
a varchar2(25);
b date;
begin
select user into a from dual;
select sysdate into b from dual;
if inserting then
update emp_test set crt_by=a and cdate=b where rowid=:new.rowid;
( i can also write rowid in (select max(rowid) from emp_test)
end if;
end;
When i am trying to insert multiple records into the table its giving me mutating table error.. I tried creating it a statement level trigger but in that case it updates only the last row of the table with user and sysdate while i want all the rows to get updated which have been inserted..
I have also tried doing it through view but it does not works..
Thanks in advance
When the going gets tough, the tough gets going