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

INSERT INTO CI_BATCH_CTRL_P (BATCH_CD,SEQ_NUM,BATCH_PARM_NAME,REQUIRED_SW,OWNER_FLG,TEXT_SECURITY_FLG) 
SELECT BC.BATCH_CD,NVL2((SELECT BCP.BATCH_CD FROM CI_BATCH_CTRL_P BCP WHERE BCP.BATCH_CD = BC.BATCH_CD AND BCP.SEQ_NUM =890),891,890) AS SEQ_NUM ,'manifestOption','N',BC.OWNER_FLG,' ' 
FROM CI_BATCH_CTRL BC 
WHERE TRIM(BC.PROGRAM_NAME) = 'com.splwg.base.domain.batch.pluginDriven.PluginDrivenExtractProcess' 
AND NOT EXISTS (SELECT 'X' FROM CI_BATCH_CTRL_P BCP WHERE BCP.BATCH_CD = BC.BATCH_CD AND BCP.BATCH_PARM_NAME = 'manifestOption')
/

INSERT INTO CI_BATCH_CTRL_P (BATCH_CD,SEQ_NUM,BATCH_PARM_NAME,BATCH_PARM_VAL,REQUIRED_SW,OWNER_FLG,TEXT_SECURITY_FLG) 
SELECT BC.BATCH_CD,NVL2((SELECT BCP.BATCH_CD FROM CI_BATCH_CTRL_P BCP WHERE BCP.BATCH_CD = BC.BATCH_CD AND BCP.SEQ_NUM =40),41,40) AS SEQ_NUM ,'manifestOption','Y','N',BC.OWNER_FLG,' ' 
FROM CI_BATCH_CTRL BC 
WHERE TRIM(BC.PROGRAM_NAME) = 'com.splwg.base.domain.dataExport.initialExportBatch.InitialExportBatchProcess' 
AND NOT EXISTS (SELECT 'X' FROM CI_BATCH_CTRL_P BCP WHERE BCP.BATCH_CD = BC.BATCH_CD AND BCP.BATCH_PARM_NAME = 'manifestOption')
/

INSERT INTO CI_BATCH_CTRL_P_L (BATCH_CD, SEQ_NUM, LANGUAGE_CD, DESCR50, DESCRLONG, VERSION, OWNER_FLG)
SELECT BCP.BATCH_CD, BCP.SEQ_NUM, 'ENG', 'Manifest Option', 'If set to ''Y'' a manifest file is created with the following name:
{batchCode}_{batchNumber}_{rerunNumber}_manifest.json', 1, BCP.OWNER_FLG
FROM CI_BATCH_CTRL_P BCP
WHERE BCP.BATCH_PARM_NAME = 'manifestOption' 
AND NOT EXISTS (SELECT 'X' FROM CI_BATCH_CTRL_P_L BCPL WHERE BCPL.LANGUAGE_CD = 'ENG' AND BCPL.BATCH_CD = BCP.BATCH_CD AND BCPL.SEQ_NUM = BCP.SEQ_NUM)
/

