create or replace TRIGGER TRIG_BRANCH_GROUP_SYNC
AFTER INSERT OR UPDATE OR DELETE
ON HRIS_BRANCHES
FOR EACH ROW
DECLARE

BEGIN
IF INSERTING
THEN

INSERT INTO hris_salary_sheet_group
(
GROUP_ID,
GROUP_CODE,
GROUP_NAME
)
VALUES
(
:new.BRANCH_ID,
:new.BRANCH_CODE,
:new.BRANCH_NAME
);
END IF;

IF UPDATING
THEN
UPDATE hris_salary_sheet_group SET GROUP_CODE = :new.BRANCH_CODE, GROUP_NAME = :new.BRANCH_NAME
WHERE GROUP_ID = :OLD.BRANCH_ID;
END IF;

IF DELETING
THEN
DELETE FROM hris_salary_sheet_group WHERE GROUP_ID = :OLD.BRANCH_ID;
END IF;
END;
