-->

Check if something exist in table sql oracle

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}



Create or replace trigger updatesummary
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;

1 comment:

  1. PYTHON Report is a data-centric blog run by a speciality executive search firm called AUTOMATIONMINDS SOLUTION Partners. Whether you are
    an intermediate level data scientist or a pro, Data Science Report has got resources for all — it delivers resources from all variety
    of formats to help the reader in understanding data science properly.

    PYTHON Training in OMR Chennai

    ReplyDelete