5 Useful SQL Scripts

download 5 Useful SQL Scripts

of 2

Transcript of 5 Useful SQL Scripts

  • 7/29/2019 5 Useful SQL Scripts

    1/2

    Add any responsibility (Even without Sysadmin)

    declarev_user_name varchar2(30):=upper('&Enter_User_Name');v_resp varchar2(30):='&Enter_Responsibility';v_resp_key varchar2(30);v_app_short_name varchar2(50);beginselect

    r.responsibility_key ,a.application_short_name

    into v_resp_key,v_app_short_namefrom fnd_responsibility_vl r,

    fnd_application_vl awhere

    r.application_id =a.application_idand upper(r.responsibility_name) = upper(v_resp);

    fnd_user_pkg.AddResp (username => v_user_name,resp_app => v_app_short_name,resp_key => v_resp_key,security_group => 'STANDARD',description => null,

    start_date => sysdate,end_date => null);commit;DBMS_OUTPUT.put_line ('Responsibility:'||v_resp||' '||'is added to the User:'|

    |v_user_name);EXCEPTIONwhen others thenDBMS_OUTPUT.put_line ('Unable to add the responsibility due to'||SQLCODE||' '|

    |SUBSTR(SQLERRM, 1, 100));rollback;

    end;

    Change User password from backend

    begin

    fnd_user_pkg.updateuser(x_user_name => '&username', x_owner => 'CUST', x_unencrypted_password => '&new_password', x_password_date => to_date('2','J'));commit;end;

  • 7/29/2019 5 Useful SQL Scripts

    2/2

    All responsibilities registered to a concurrent program

    select frt.responsibility_name, frg.request_group_name,frgu.request_unit_type,frgu.request_unit_id,fcpt.user_concurrent_program_nameFrom fnd_Responsibility fr, fnd_responsibility_tl frt,fnd_request_groups frg, fnd_request_group_units frgu,fnd_concurrent_programs_tl fcptwhere frt.responsibility_id = fr.responsibility_idand frg.request_group_id = fr.request_group_idand frgu.request_group_id = frg.request_group_idand fcpt.concurrent_program_id = frgu.request_unit_idand frt.language = USERENV('LANG')and fcpt.language = USERENV('LANG')and fcpt.user_concurrent_program_name = :conc_prg_nameorder by 1,2,3,4

    All Profile options

    SELECT SUBSTR(e.profile_option_name,1,30) PROFILE,DECODE(a.level_id,10001,'Site',10002,'Application',10003,'Responsibility',10

    004,'User') L,DECODE(a.level_id,10001,'Site',10002,c.application_short_name,10003,b.respon

    sibility_name,10004,d.user_name) LValue,NVL(a.profile_option_value,'Is Null') Value,SUBSTR(a.last_update_date,1,25) UPDATED_DATE

    FROM fnd_profile_option_values aINNER JOIN fnd_profile_options e ON a.profile_option_id = e.profile_option_idLEFT OUTER JOIN fnd_responsibility_tl b ON a.level_value = b.responsibility_idLEFT OUTER JOIN fnd_application c ON a.level_value = c.application_idLEFT OUTER JOIN fnd_user d ON a.level_value = d.user_idWHERE e.profile_option_name LIKE '%&1%'ORDER BY profile_option_name;