__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
WHERE SCRIPT_FILE_NAME = 'FW44030_POSTDATA_UGBUPD-7682.SQL'
   AND END_DTTM IS NOT NULL
/
__THEN__
__EXIT__
__ENDIF__

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1TABLE',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILETBLP' 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='F1TABLE')
/

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

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1WRKCLQ',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILTCLWP' 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='F1WRKCLQ')
/

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

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1WRKCAL',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILTCLWP' 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='F1WRKCAL')
/

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

Update ci_fk_ref set zone_cd = 'F1-WORKCALQ' where fk_ref_cd = 'F1-CAL' and zone_cd = 'F1-WORKCAL'
/

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1MSG',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILTMSGP' 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='F1MSG')
/

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

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1MSGC',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILTMSGP' 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='F1MSGC')
/

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

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1MSGQ',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILTMSGP' 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='F1MSGQ')
/

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

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1TODOEQ',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILQTDEP' 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='F1TODOEQ')
/

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

Insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) Select USR_GRP_ID,'F1TODO',EXPIRATION_DT,1,OWNER_FLG From sc_usr_grp_prof A Where A.App_Svc_Id = 'CILQTDEP' 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='F1TODO')
/

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

Update ci_fk_ref set zone_cd = 'F1-TDEQRY' where fk_ref_cd = 'F1-TODO' and zone_cd = ' '
/

Update ci_fk_ref set zone_cd = 'F1-TDEQRY' where fk_ref_cd = 'C1-TODO' and zone_cd = ' '
/

insert into sc_usr_grp_prof (USR_GRP_ID,APP_SVC_ID,EXPIRATION_DT,VERSION,OWNER_FLG) select USR_GRP_ID, 'F1TMZNM', EXPIRATION_DT, 1, OWNER_FLG from sc_usr_grp_prof A where A.APP_SVC_ID = 'CILTTZNP' 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='F1TMZNM')
/

insert into sc_access_cntl (USR_GRP_ID,APP_SVC_ID,ACCESS_MODE,VERSION,OWNER_FLG) select USR_GRP_ID,'F1TMZNM','R',1,OWNER_FLG from SC_ACCESS_CNTL A where A.APP_SVC_ID='CILTTZNP' And A.ACCESS_MODE = 'R' and not exists (select 1 from sc_access_cntl B where B.USR_GRP_ID=A.USR_GRP_ID and B.APP_SVC_ID='F1TMZNM' and B.ACCESS_MODE='R')
/