__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
WHERE SCRIPT_FILE_NAME = 'FW44021_POSTDATA_OUAF-16034.sql'
   AND END_DTTM IS NOT NULL
/
__THEN__
__EXIT__
__ENDIF__


update f1_bus_obj set app_svc_id = 'F1-ETLMAPBOAS' where bus_obj_cd = 'F1-ETLMapCtrl' and APP_SVC_ID = 'F1-ETLMPCTRL'
/

update f1_bus_obj set app_svc_id = 'F1-CHARMAPBOAS' where bus_obj_cd = 'F1-CharMapping' and APP_SVC_ID = 'F1-ETLMPCTRL'
/

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1CHRMAP',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'F1ETL' and Not Exists(Select 1 From sc_usr_grp_prof B Where B.USR_GRP_ID=A.USR_GRP_ID And B.App_Svc_ID='F1CHRMAP')
/

Insert into sc_access_cntl (USR_GRP_ID,APP_SVC_ID,ACCESS_MODE,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1CHRMAP',ACCESS_MODE,1,OWNER_FLG From SC_Access_CNTL A Where A.App_Svc_ID='F1ETL' And Not Exists(Select 1 From Sc_Access_Cntl B Where B.Usr_Grp_ID=A.Usr_Grp_ID and B.App_Svc_ID='F1CHRMAP' and B.Access_Mode=A.ACCESS_MODE)
/

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1-ETLMAPBOAS',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'F1-ETLMPCTRL' and Not Exists(Select 1 From sc_usr_grp_prof B Where B.USR_GRP_ID=A.USR_GRP_ID And B.App_Svc_ID='F1-ETLMAPBOAS')
/

Insert into sc_access_cntl (USR_GRP_ID,APP_SVC_ID,ACCESS_MODE,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1-ETLMAPBOAS',ACCESS_MODE,1,OWNER_FLG From SC_Access_CNTL A Where A.App_Svc_ID='F1-ETLMPCTRL' And Not Exists(Select 1 From Sc_Access_Cntl B Where B.Usr_Grp_ID=A.Usr_Grp_ID and B.App_Svc_ID='F1-ETLMAPBOAS' and B.Access_Mode=A.ACCESS_MODE)
/
