Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table track_sal_emp (
- id_emp numeric not null,
- dif_sal numeric
- );
- create or replace function process_dif_sal() RETURNS TRIGGER AS $new_Emp$
- BEGIN
- if(TG_OP = 'UPDATE') THEN
- insert into track_sal_emp (id_emp, dif_sal) VALUES(OLD.empno, NEW.sal - OLD.sal);
- END if;
- return null;
- end;
- $new_Emp$ LANGUAGE plpgsql;
- CREATE TRIGGER chek_dif_sal
- AFTER INSERT OR UPDATE OR DELETE ON new_emp
- FOR EACH ROW EXECUTE FUNCTION process_dif_sal();
- UPDATE new_Emp
- SET sal = 5000
- where sal between 4000 and 4500;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement