Question:
My code works until it reachs last line then it throws a syntax error.
Error :
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0104N An unexpected token "temp_dept" was found following "(case when ". Expected tokens may include: "JOIN". SQLSTATE=42601
I am trying to do this:
- After each insert on RD_EMP
- for each row
- insert into RD_Supervisor
- check for cases, if temp_dept.RD_E_ID <= 0 THEN RD_Supervisor.RD_E_SUP 0
Code:
create trigger RD_total_dep_emp \
after insert on RD_Emp \
referencing new table as temp_dept
for each statement \
insert into RD_Supervisor(RD_E_SUP, RD_E_EMP, RD_QUOT) \
select temp_dept.RD_E_ID,
(case \
when temp_dept.RD_E_ID <= 0 then 0 \
when temp_dept.RD_E_ID > 0 AND temp_dept.RD_E_ID <= 15 then 15 \
when temp_dept.RD_E_ID > 15 AND temp_dept.RD_E_ID <= 25 then 25 \
when temp_dept.RD_E_ID > 25 AND temp_dept.RD_E_ID <= 35 then 35 \
when temp_dept.RD_E_ID > 35 then 100 \
end) as RD_E_SUP \
from temp_dept