CREATE OR REPLACE PROCEDURE xxx_create_user_p
IS
l_password VARCHAR2 (30) := 'welcome123';
l_session_id NUMBER := USERENV ('sessionid');
l_err_msg VARCHAR2 (2000) := NULL;
CURSOR get_details
IS
SELECT audt.*, per.person_id
FROM xxx_user_details_t audt, per_people_x per
WHERE per.employee_number = audt.employee_number;
BEGIN
FOR fetch_details IN get_details
LOOP
BEGIN
fnd_user_pkg.
createuser (
x_user_name => fetch_details.user_name,
x_owner => NULL,
x_unencrypted_password => l_password,
x_session_number => l_session_id,
x_start_date => fetch_details.start_date,
x_end_date => NULL,
x_email_address => fetch_details.email_address);
UPDATE xxx_user_details_t audt
SET audt.process_flag = 'Y', err_msg = NULL
WHERE audt.user_name = fetch_details.user_name;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
l_err_msg := SQLERRM;
UPDATE xxx_user_details_t audt
SET audt.process_flag = 'N', err_msg = l_err_msg
WHERE audt.user_name = fetch_details.user_name;
COMMIT;
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Failed' || SUBSTR (SQLERRM, 1, 100));
-- ROLLBACK;
END;
No comments:
Post a Comment