设为首页 收藏本站
查看: 1305|回复: 0

[经验分享] EBS中如何后台批量更改Profiles的值

[复制链接]

尚未签到

发表于 2017-5-24 07:47:27 | 显示全部楼层 |阅读模式
  EBS中如何后台批量更改Profiles的值
  (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处;否则请与本人联系,违者必究)
  自己写来管理自己负责维护的EBS instance,经常有人设置了一些调试用的profile忘记关闭,结果导致服务器性能变差,可用空间变小,所以写了这个脚本。

  1.如果要增加修改的profile, 需要同时在l_profNames 增加变量名, 在 l_profNewVal增加变量值。
  2.l_profSpeUser, 如果只更改一个用户的profile值,就需要设置这个用户名,必须大写,而且这个值拥有最高优先级。
  3.l_profSpeResp, 如果只更改一个职责的profile值,就需要设置这个职责名,而且这个值拥有第二高优先级。
  4.l_profSpeApp, 如果只更改一个应用的profile值,就需要设置这个用户名,必须大写,而且这个值拥有第三最高优先级。
  5.如果即不指明用户,职责和应用,那就对所有层次更新所有层次的profiles。
  6.l_profExceptUser, 如果对所有层次更新profiles,那么这里指定的用户会被忽略,不会被更新,用户名要大写。
  7.l_profIncludeSite,如果对所有层次更新profiles的时候,这个变量指明会不会更新站点层次的值。'N'是不更新,'Y'是更新。


/**
* Batch update profile values from back end. Mainly used to
* enable/disable debug profiles on dev instance
* Author:tavor
* Date:2014-01-08
* Revision:1
*******************************************************************************************
**** IF YOU ARE NOT INSTANCE OWNER/ADMINISTRATOR, PLEASE BE CAREFUL TO RUN THIS SCRIPT*****
*******************************************************************************************
* 1.If need to add more profile, need to specify profile name in l_profNames
* and new value in l_profNewVal.
* 2.l_profSpeUser is the user we just update profile for him/her, and this has highest priority.
* 3.l_profSpeResp is the resp we just update profile for it, and this has less higher priority.
* 4.l_profSpeApp is the App we just update profile for it, and this has less the third high priority.
* 5.If l_profSpeUser, l_profSpeResp and l_profSpeApp are all null, then we will update profiles for
* all resp, user and app level.
* 6.l_profExceptUser, If we update profiles for all levels, we will not update profile values
* for this user.
* 7.l_profIncludeSite, when we update profiels for all levels, this variable indidate if we also
* update profile values at site level. 'N', will not udpate for site for level, 'Y' for the opposite.
**/
DECLARE
--l_profCount NUMBER :=3;
TYPE HWDebugType IS VARRAY(10) OF VARCHAR2(240);
l_profNames HWDebugType;
l_profIDs HWDebugType;
l_profNewVal HWDebugType;
l_profIncSite HWDebugType;
l_profAllLevel HWDebugType;
l_profSpeUser VARCHAR2(20) := 'HONWEI1';--this should be in upper case
l_profSpeUserID NUMBER := NULL;
l_profSpeResp VARCHAR2(20) := NULL;
l_profSpeRespID NUMBER := NULL;
l_profSpeApp VARCHAR2(20) := NULL;
l_profSpeAppID NUMBER := NULL;
l_profExceptUser VARCHAR2(20) := NULL;--this should be in upper case
l_profExceptUserID NUMBER :=NULL;
l_profIncludeSite VARCHAR2(5) := 'N';
l_userLevel NUMBER := 10004;
l_respLevel NUMBER := 10003;
l_appLevel  NUMBER := 10002;
l_siteLevel NUMBER := 10001;
l_profileId NUMBER := NULL;
l_space     VARCHAR2(20)  :='   ';

CURSOR CURRENT_PROFILE_VALUES (p_profileName VARCHAR2) IS
SELECT  a.profile_option_id,t.user_profile_option_name cProfileOption,
decode(a.level_id,     10001,     'Site',
10002,     'Application',
10003,     'Responsibility',
10004,     'User') cLevel,
decode(a.level_id,     10001,     'Site',
10002,     b.application_short_name,
10003,     c.responsibility_key,
10004,     d.user_name) cLevelValue,
a.profile_option_value cProfileValue
FROM fnd_profile_option_values a,
fnd_application b,
fnd_responsibility c,
fnd_user d,
fnd_profile_options e,
fnd_profile_options_tl t
WHERE a.profile_option_id = e.profile_option_id
AND e.profile_option_name = p_profileName
AND a.level_value = b.application_id(+)
AND a.level_value = c.responsibility_id(+)
AND a.level_value = d.user_id(+)
AND t.profile_option_name = e.profile_option_name
AND t.LANGUAGE = 'US'
ORDER BY a.profile_option_id,e.profile_option_name, a.level_id DESC;
l_curProfileValues CURRENT_PROFILE_VALUES%ROWTYPE;
BEGIN
l_profNames := HWDebugType( 'INV_DEBUG_TRACE'    --
--,'AFLOG_ENABLED'     --
--,'ICX_FORMS_LAUNCHER'--
);
l_profNewVal := HWDebugType( '2'    --
--   ,'N'     --
--   ,NULL--
);
l_profIncSite := HWDebugType('Y'    --
,'Y'     --
,'N'--
);
l_profAllLevel := HWDebugType('Y'    --
,'Y'     --
,'Y'--
);
IF l_profSpeUser IS NOT NULL AND l_profSpeUserID IS NULL THEN
SELECT USER_ID
INTO   l_profSpeUserID
FROM   FND_USER
WHERE  user_name = l_profSpeUser;
END IF;
Dbms_Output.put_line('Specified User:'||l_profSpeUser||', ID:'||l_profSpeUserID);

IF l_profExceptUser IS NOT NULL AND l_profExceptUserID IS NULL THEN
SELECT USER_ID
INTO   l_profExceptUserID
FROM   FND_USER
WHERE  user_name = l_profExceptUser;
END IF;
Dbms_Output.put_line('Except for User:'||l_profExceptUser||', ID:'||l_profExceptUserID);

IF l_profSpeResp IS NOT NULL AND l_profSpeRespID IS NULL THEN
SELECT responsibility_id
INTO   l_profSpeRespID
FROM   FND_RESPONSIBILITY_VL
WHERE  responsibility_name =l_profSpeResp;
END IF;
Dbms_Output.put_line('specified Responsibility:'||l_profSpeResp||', ID:'||l_profSpeRespID);

IF l_profSpeApp IS NOT NULL AND l_profSpeAppID IS NULL THEN
SELECT APPLICATION_ID
INTO   l_profSpeAppID
FROM   FND_APPLICATION_VL
WHERE  APPLICATION_NAME = l_profSpeApp;
END IF;
Dbms_Output.put_line('specified Application:'||l_profSpeApp||', ID:'||l_profSpeAppID);


FOR i IN 1..l_profNames.count loop
Dbms_Output.put_line('profile name:'||l_profNames(i));
Dbms_Output.put_line('Profile Option'||l_space||'Level'||l_space||'Level Value'||l_space||'Profile Value');
FOR currProf_rec IN CURRENT_PROFILE_VALUES(l_profNames(i)) LOOP
Dbms_Output.put_line(currProf_rec.cProfileOption||l_space||currProf_rec.cLevel||l_space||currProf_rec.cLevelValue||l_space||currProf_rec.cProfileValue);
END LOOP;
SELECT profile_option_id
INTO   l_profileId
FROM   fnd_profile_options
WHERE  profile_option_name = l_profNames(i);
if l_profSpeUserID is NOT null THEN
UPDATE fnd_profile_option_values
SET    profile_option_value = l_profNewVal(i) -- profile value
WHERE  profile_option_id = l_profileId        -- profile id
AND    level_id    = l_userLevel              -- level  id
AND    level_value = l_profSpeUserID          -- level value
AND    profile_option_value <> l_profNewVal(i);
Dbms_Output.put_line('Have set profiles at user level for userID:'||l_profSpeUserID);
elsif l_profSpeRespID is NOT null THEN
UPDATE fnd_profile_option_values
SET    profile_option_value = l_profNewVal(i) -- profile value
WHERE  profile_option_id = l_profileId        -- profile id
AND    level_id    = l_respLevel              -- level  id
AND    level_value = l_profSpeRespID          -- level value
AND    profile_option_value <> l_profNewVal(i);
Dbms_Output.put_line('Have set profiles at resp level for respID:'||l_profSpeRespID);
elsif l_profSpeAppID is NOT null THEN
UPDATE fnd_profile_option_values
SET    profile_option_value = l_profNewVal(i) -- profile value
WHERE  profile_option_id = l_profileId        -- profile id
AND    level_id    = l_appLevel               -- level  id
AND    level_value = l_profSpeAppID           -- level value
AND    profile_option_value <> l_profNewVal(i);
Dbms_Output.put_line('Have set profiles at app level for appID:'||l_profSpeAppID);
ELSE
UPDATE fnd_profile_option_values
SET    profile_option_value = l_profNewVal(i) -- profile value
WHERE  profile_option_id = l_profileId        -- profile id
AND    profile_option_value <> l_profNewVal(i)
AND    level_id <> Decode(l_profIncludeSite, 'Y', -1, l_siteLevel)
AND    (  (l_profExceptUserID IS NOT NULL AND (    (level_value <> l_profExceptUserID AND level_id = l_userLevel)
OR (level_id <> l_userLevel)))
OR l_profExceptUserID IS NULL);
Dbms_Output.put_line('Have set profiles for all level, l_profIncludeSite:'||l_profIncludeSite||',l_profExceptUserID:'||l_profExceptUserID);
end if;
Dbms_Output.put_line('After update profile value for profile name:'||l_profNames(i));
Dbms_Output.put_line('Profile Option'||l_space||'Level'||l_space||'Level Value'||l_space||'Profile Value');
FOR currProf_rec IN CURRENT_PROFILE_VALUES(l_profNames(i)) LOOP
Dbms_Output.put_line(currProf_rec.cProfileOption||l_space||currProf_rec.cLevel||l_space||currProf_rec.cLevelValue||l_space||currProf_rec.cProfileValue);
END LOOP;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
Dbms_Output.put_line('SQLCODE:'||SQLCODE||', SQLERRM:'||SQLERRM);
END;

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-380196-1-1.html 上篇帖子: EBS OAF 开发中的实体关联关系对象AO 下篇帖子: EBS Form开发中通过Radio Button来调用LOV实现实例(4)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表