/* Formatted on 20-Mar-18 4:38:03 PM (QP5 v5.114.809.3010) */
DECLARE
ld_password_lifespan_days NUMBER := 90;
lc_email_address VARCHAR2 (100);
l_count NUMBER := 0;
l_error NUMBER;
l_error_msg VARCHAR2 (4000);
CURSOR c1
IS
SELECT USER_NAME,
PASSWORD,
(SELECT DISTINCT PERSON_ID
FROM PER_ALL_PEOPLE_F
WHERE EMPLOYEE_NUMBER = t.EMPLOYEE_NUMBER
AND BUSINESS_GROUP_ID IN (81, 82))
PERSON_ID,
(SELECT DISTINCT EMAIL_ADDRESS
FROM PER_ALL_PEOPLE_F
WHERE EMPLOYEE_NUMBER = t.EMPLOYEE_NUMBER
AND effective_start_date >= '01-Apr-2018'
AND BUSINESS_GROUP_ID IN (81, 82))
EMAIL_ADDRESS,
PROCESS_FLAG,
ERROR_MESSAGE
FROM XXHRL_USERS_LOAD t;
BEGIN
FOR i IN c1
LOOP
BEGIN
DBMS_OUTPUT.put_line ('In Loop');
l_error := 0;
fnd_user_pkg.UpdateUser (
x_user_name => i.USER_NAME,
x_owner => NULL,
x_employee_id => i.PERSON_ID,
x_email_address => i.EMAIL_ADDRESS1
);
l_count := l_count + 1;
DBMS_OUTPUT.put_line ('l_count: ' || l_count);
UPDATE XXHRL_USERS_LOAD
SET process_flag = 'Y', error_message = 'Loaded'
WHERE USER_NAME = i.USER_NAME;
EXCEPTION
WHEN OTHERS
THEN
l_error := 1;
l_error_msg := 'Update user Api Exception ' || SQLERRM;
DBMS_OUTPUT.put_line (SQLERRM);
END;
IF l_error = 1
THEN
UPDATE XXHRL_USERS_LOAD
SET process_flag = 'N', error_message = l_error_msg
WHERE USER_NAME = i.USER_NAME;
END IF;
l_error := 0;
l_error_msg := NULL;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK;
DBMS_OUTPUT.put_line (SQLERRM);
END;
0 Comments