Hi,
I need some help in correcting my fault in the below trigger as it is not working as expected.
. trigger should be invoked if while modifying the sal in EMP table, it is not in the valid range as specified in the SALGRADE table (between lowest losal and highest hisal)
salgrade table
Column Name | Data Type | Nullable | Default | Primary Key |
---|
GRADE | NUMBER(2,0) | Yes | - | - |
LOSAL | NUMBER | Yes | - | - |
HISAL | NUMBER | Yes | - | - |
I have created a trigger
create or replace trigger tr_validate_sal
before
insert or update on emp
for each row
declare
cursor c is select losal,hisal from salgrade;
begin
for i in c
loop
if :new.sal < i.losal and :new.sal > i.hisal
then
raise_application_error(-20400,'sal out of range');
end if;
end loop;
end;
after creating this trigger also i am able to insert or update salary not in range of salgrade (losal and hisal). please help.