DECLARE
  V_EMPLOYEE_ID NUMBER(7,0);
  V_FIRST_NAME  VARCHAR2(255 BYTE);
  V_MIDDLE_NAME VARCHAR2(255 BYTE);
  V_LAST_NAME   VARCHAR2(255 BYTE);
  V_FULL_NAME   VARCHAR(255 BYTE);
  CURSOR EMPLOYEES
  IS
    (SELECT EMPLOYEE_ID, FIRST_NAME,MIDDLE_NAME,LAST_NAME FROM HRIS_EMPLOYEES
    );
BEGIN
  OPEN EMPLOYEES;
  LOOP
    EXIT
  WHEN EMPLOYEES%NOTFOUND;
    FETCH EMPLOYEES INTO V_EMPLOYEE_ID,V_FIRST_NAME,V_MIDDLE_NAME,V_LAST_NAME;
    UPDATE HRIS_EMPLOYEES
    SET FULL_NAME= CONCAT(CONCAT(CONCAT(TRIM(V_FIRST_NAME),' '),
      CASE
        WHEN V_MIDDLE_NAME IS NOT NULL
        THEN CONCAT(TRIM(V_MIDDLE_NAME), ' ')
        ELSE ''
      END ),TRIM(V_LAST_NAME))
    WHERE EMPLOYEE_ID=V_EMPLOYEE_ID;
    NULL;
  END LOOP;
  CLOSE EMPLOYEES;
END;

