__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
WHERE SCRIPT_FILE_NAME = 'FW45010_APDATA_UGBUPD-10242_OUAF-35869.SQL'
   AND END_DTTM IS NOT NULL
/
__THEN__
__EXIT__
__ENDIF__


-- Update the batch control and related To Do Type to 'CM' if you find a Batch Run instance. Otherwise delete the non-owned To Do child tables.

__IF_EXISTS__
select 1 from CI_BATCH_RUN where BATCH_CD = 'F1-RMMSG'
/

__THEN__
update CI_BATCH_CTRL set OWNER_FLG = 'CM', APP_SVC_ID = 'F1-DFLTS' where BATCH_CD = 'F1-RMMSG'
/
update CI_BATCH_CTRL_L set OWNER_FLG = 'CM' where BATCH_CD = 'F1-RMMSG'
/
UPDATE CI_BATCH_CTRL_L SET DESCR = DESCR || ' (Deprecated)', DESCRLONG = 'This Batch Control is no longer supported.  It is retained for backward compatibility reasons only. ' || DESCRLONG WHERE BATCH_CD = 'F1-RMMSG' AND LANGUAGE_CD = 'ENG'
/
update CI_BATCH_CTRL_P set OWNER_FLG = 'CM' where BATCH_CD = 'F1-RMMSG'
/
update CI_BATCH_CTRL_P_L set OWNER_FLG = 'CM' where BATCH_CD = 'F1-RMMSG'
/
update CI_TD_TYPE set OWNER_FLG = 'CM', NAV_OPT_CD = 'f1todoTabMenu' where TD_TYPE_CD = 'F1-RMMON'
/
update CI_TD_DRLKEY_TY set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMON'
/
update CI_TD_SRTKEY_TY set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMON'
/
update CI_TD_SRTKEY_TY_L set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMON'
/
update CI_TD_TYPE_L set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMON'
/
update CI_TD_TYPE_L set DESCR = DESCR || ' (Deprecated)', DESCRLONG = 'This To Do Type is no longer supported.  It is retained for backward compatibility reasons only.  Its navigation option refers to To Do Entry as the original navigation option is no longer supported. ' || DESCRLONG WHERE TD_TYPE_CD = 'F1-RMMON' AND LANGUAGE_CD = 'ENG'
/
__ELSE__
Delete from CI_CHTY_TDTY where TD_TYPE_CD = 'F1-RMMON'
/
Delete from CI_TD_EX_LIST where TD_TYPE_CD = 'F1-RMMON'
/
Delete from CI_TD_TYPE_ALG where TD_TYPE_CD = 'F1-RMMON'
/
Delete from CI_TD_TYPE_CHAR where TD_TYPE_CD = 'F1-RMMON'
/
Delete from CI_TD_VAL_ROLE where TD_TYPE_CD = 'F1-RMMON'
/
Delete from CI_ACC_GRP_ROLE where TD_TYPE_CD = 'F1-RMMON'
/
__ENDIF__

-- Update the To Do Type to 'CM' if you find a To Do Entry instance. Otherwise delete the non-owned To Do child tables.

__IF_EXISTS__
select 1 from CI_TD_ENTRY where TD_TYPE_CD = 'F1-RMMSG'
/

__THEN__
update CI_TD_TYPE set OWNER_FLG = 'CM', NAV_OPT_CD = 'toDoEntryMaint' where TD_TYPE_CD = 'F1-RMMSG'
/
update CI_TD_DRLKEY_TY set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMSG'
/
update CI_TD_SRTKEY_TY set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMSG'
/
update CI_TD_SRTKEY_TY_L set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMSG'
/
update CI_TD_TYPE_L set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-RMMSG'
/
update CI_TD_TYPE_L set DESCR = DESCR || ' (Deprecated)', DESCRLONG = 'This To Do Type is no longer supported.  It is retained for backward compatibility reasons only.  Its navigation option refers to To Do Entry as the original navigation option is no longer supported. ' || DESCRLONG WHERE TD_TYPE_CD = 'F1-RMMSG' AND LANGUAGE_CD = 'ENG'
/

__ELSE__

Delete from CI_CHTY_TDTY where TD_TYPE_CD = 'F1-RMMSG'
/
Delete from CI_TD_EX_LIST where TD_TYPE_CD = 'F1-RMMSG'
/
Delete from CI_TD_TYPE_ALG where TD_TYPE_CD = 'F1-RMMSG'
/
Delete from CI_TD_TYPE_CHAR where TD_TYPE_CD = 'F1-RMMSG'
/
Delete from CI_TD_VAL_ROLE where TD_TYPE_CD = 'F1-RMMSG'
/
Delete from CI_ACC_GRP_ROLE where TD_TYPE_CD = 'F1-RMMSG'
/

__ENDIF__

-- Update the batch control to 'CM' if you find a Batch Run instance.

__IF_EXISTS__
select 1 from CI_BATCH_RUN where BATCH_CD = 'F1-RMCRL'
/

__THEN__
update CI_BATCH_CTRL set OWNER_FLG = 'CM', APP_SVC_ID = 'F1-DFLTS' where BATCH_CD = 'F1-RMCRL'
/
update CI_BATCH_CTRL_L set OWNER_FLG = 'CM' where BATCH_CD = 'F1-RMCRL'
/
UPDATE CI_BATCH_CTRL_L SET DESCR = DESCR || ' (Deprecated)', DESCRLONG = 'This Batch Control is no longer supported.  It is retained for backward compatibility reasons only. ' || DESCRLONG WHERE BATCH_CD = 'F1-RMCRL' AND LANGUAGE_CD = 'ENG'
/
update CI_BATCH_CTRL_P set OWNER_FLG = 'CM' where BATCH_CD = 'F1-RMCRL'
/
update CI_BATCH_CTRL_P_L set OWNER_FLG = 'CM' where BATCH_CD = 'F1-RMCRL'
/

__ELSE__
__ENDIF__
