__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
WHERE SCRIPT_FILE_NAME = 'FW45010_APDATA_UGBUPD-10242_OUAF-36649.SQL'
   AND END_DTTM IS NOT NULL
/
__THEN__
__EXIT__
__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-DPLFD'
/

__THEN__
update CI_TD_TYPE set OWNER_FLG = 'CM', NAV_OPT_CD = 'toDoEntryMaint' where TD_TYPE_CD = 'F1-DPLFD'
/
update CI_TD_DRLKEY_TY set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-DPLFD'
/
update CI_TD_SRTKEY_TY set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-DPLFD'
/
update CI_TD_SRTKEY_TY_L set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-DPLFD'
/
update CI_TD_TYPE_L set OWNER_FLG = 'CM' where TD_TYPE_CD = 'F1-DPLFD'
/
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-DPLFD' AND LANGUAGE_CD = 'ENG'
/

__ELSE__

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

__ENDIF__

