среда, 5 декабря 2012 г.

API добавления полномочия для пользователя

С помощью данного API можно добавить полномочие пользователю1

 begin
-- Call the procedure
fnd_user_pkg.addresp(username => :username,
resp_app => :resp_app,
resp_key => :resp_key,
security_group => :security_group, -- в основном 'STANDARD'
description => :description, -- любой коммент
start_date => :start_date,
end_date => :end_date);
commit;
dbms_output.put_line('Responsibility Added Successfully');
exception
when others then
dbms_output.put_line(' Responsibility is not added due to '
|| substr(SQLERRM, 1, 100));
rollback;
end;



И весьма полезный скрипт, c помощью которого можно быстро перетянуть полномочия с одного инстанса на другой.

declare
l_user_name varchar2(100) := 'USER_NAME';
begin
dbms_output.put_line('BEGIN');
-- цикл по списку полномочий пользователя
for i in (select 'fnd_user_pkg.addresp('''||u.user_name||''', '''
|| a.application_short_name ||''', '''
|| r.responsibility_key ||''', '''
|| 'STANDARD' ||''', '''
|| 'Add by script' ||''', '
|| 'sysdate' ||', '
|| 'null' ||');'
as script
, r.responsibility_name
from fnd_user u
,fnd_user_resp_groups g
,fnd_application_vl a
,fnd_responsibility_vl r
where g.user_id(+) = u.user_id
and g.responsibility_application_id = a.application_id
and a.application_id = r.application_id
and g.responsibility_id = r.responsibility_id
AND u.user_name = l_user_name
)
loop
dbms_output.put_line(' dbms_output.put_line('''||i.responsibility_name||''');');
dbms_output.put_line(' '||i.script);
dbms_output.put_line('');
end loop;
dbms_output.put_line(' commit;');
dbms_output.put_line(' dbms_output.put_line('''');');
dbms_output.put_line(' dbms_output.put_line(''Responsibility Added Successfully'');');
dbms_output.put_line('EXCEPTION');
dbms_output.put_line(' when others then');
dbms_output.put_line(' dbms_output.put_line('' Responsibility is not added due to '' || substr(SQLERRM, 1, 100));');
dbms_output.put_line(' rollback;');
dbms_output.put_line('END;');
end;

1 комментарий: