DECLARE
duplicate_responsibility EXCEPTION;
PRAGMA EXCEPTION_INIT (duplicate_responsibility, -20001);
i INTEGER := 0;
no_action_required EXCEPTION;
p_user_id NUMBER (10);
CURSOR c_get
IS
SELECT *
FROM fnd_responsibility_vl
WHERE 1 = 1
AND ( UPPER (responsibility_name) LIKE '%PA%SUPERUSER'
OR UPPER (responsibility_name) LIKE '%AP%SUPERUSER'
OR UPPER (responsibility_name) LIKE '%GL%SUPERUSER'
OR responsibility_name LIKE 'Functional Administrator'
OR responsibility_name LIKE 'System Administrator'
);
/*CURSOR c_get
IS
SELECT *
FROM fnd_responsibility_vl
WHERE UPPER (responsibility_name) LIKE '%PA%SUPERUSER';*/
BEGIN
SELECT user_id
INTO p_user_id
FROM fnd_user
WHERE user_name = 'AAGRA7';
FOR p_rec IN c_get
LOOP
BEGIN
fnd_user_resp_groups_api.insert_assignment
(user_id => p_user_id,
responsibility_id => p_rec.responsibility_id,
responsibility_application_id => p_rec.application_id,
security_group_id => 0,
start_date => SYSDATE - 1,
end_date => NULL,
description => 'UPLOAD VIA SCRIPT'
);
EXCEPTION
WHEN duplicate_responsibility
THEN
fnd_user_resp_groups_api.update_assignment
(user_id => p_user_id,
responsibility_id => p_rec.responsibility_id,
responsibility_application_id => p_rec.application_id,
security_group_id => 0,
start_date => SYSDATE - 1,
end_date => NULL,
description => 'UPDATE VIA SCRIPT'
);
END;
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
COMMIT;
END;
No comments:
Post a Comment