I wanted to assign a condition which checks if something exist in (x,y,z..) in trigger but I could not check this because you cant use subqueries in trigger and can not store more than one values in a variable but you can achieve the purpose by using select count(xyz) into variable from ABC (table) where ________
For example
Imp(empno, ename, Job, salary)
Summary(Job,Num) {Num=total no of employees for each job in imp table}
Summary(Job,Num) {Num=total no of employees for each job in imp table}
Create or replace trigger updatesummary
before insert on imp
For each row
Declare no_of_emp Number ;
Begin
before insert on imp
For each row
Declare no_of_emp Number ;
Begin
Select count(empno) into no_of_emp from imp where job=:new.job;
If no_of_emp=0 then
insert into summary values(:new.job,No_of_Emp+1);
else update summary set NUM=No_of_emp+1 where job=:new.job;
End if;
end;
insert into summary values(:new.job,No_of_Emp+1);
else update summary set NUM=No_of_emp+1 where job=:new.job;
End if;
end;