DECLARE
  V_DISTRICT_ID NUMBER;
  V_ZONE_ID     NUMBER;
BEGIN
  FOR employees IN
  (SELECT EMPLOYEE_ID, ADDR_PERM_VDC_MUNICIPALITY_ID FROM HRIS_EMPLOYEES
  )
  LOOP
    IF (employees.ADDR_PERM_VDC_MUNICIPALITY_ID IS NOT NULL) THEN
      SELECT V.DISTRICT_ID,
        D.ZONE_ID
      INTO V_DISTRICT_ID,
        V_ZONE_ID
      FROM HRIS_VDC_MUNICIPALITIES V
      JOIN HRIS_DISTRICTS D
      ON (D.DISTRICT_ID          = V.DISTRICT_ID)
      WHERE V.VDC_MUNICIPALITY_ID= employees.ADDR_PERM_VDC_MUNICIPALITY_ID;
      UPDATE HRIS_EMPLOYEES
      SET ADDR_PERM_DISTRICT_ID = V_DISTRICT_ID ,
        ADDR_PERM_ZONE_ID       = V_ZONE_ID
      WHERE EMPLOYEE_ID         = employees.EMPLOYEE_ID;
    END IF;
  END LOOP;
END;
-- END FOR PERM

DECLARE
  V_DISTRICT_ID NUMBER;
  V_ZONE_ID     NUMBER;
BEGIN
  FOR employees IN
  (SELECT EMPLOYEE_ID, ADDR_TEMP_VDC_MUNICIPALITY_ID FROM HRIS_EMPLOYEES
  )
  LOOP
    IF (employees.ADDR_TEMP_VDC_MUNICIPALITY_ID IS NOT NULL) THEN
      SELECT V.DISTRICT_ID,
        D.ZONE_ID
      INTO V_DISTRICT_ID,
        V_ZONE_ID
      FROM HRIS_VDC_MUNICIPALITIES V
      JOIN HRIS_DISTRICTS D
      ON (D.DISTRICT_ID          = V.DISTRICT_ID)
      WHERE V.VDC_MUNICIPALITY_ID= employees.ADDR_TEMP_VDC_MUNICIPALITY_ID;
      UPDATE HRIS_EMPLOYEES
      SET ADDR_TEMP_DISTRICT_ID = V_DISTRICT_ID ,
        ADDR_TEMP_ZONE_ID       = V_ZONE_ID
      WHERE EMPLOYEE_ID         = employees.EMPLOYEE_ID;
    END IF;
  END LOOP;
END;
-- END FOR TEMP