I have two tables: table1 and table2, and i want to create a trigger like:
create or replace trigger trig_1
after insert on table1
update table2 set col1 = ....(based on sum(col2 of table1))
Within this trigger i want to update table2. This update is based on column1 in table1(basically on summation of column1 for table1), if i do "select sum(col1) from table1" ---- they must be mutating, please help.
BTW, there is not foreign key relationship and the col1 in table2, col2 in table1 are not keys in both tables.
Basically, i create variables in my package, then create a trigger "before insert on table1 for each row", store the key in one of the variables created in my package;create second trigger "before insert on table1" statement level, select(sum) the column i wanted based on the variable i stored formly, store the summation to another variable in the package; last, create trigger "after insert on table1 for each row" and do whatever you want based on the infos stroed in the variables in the package.