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

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, 140, 'allowAppendTable', ' ', 'N', BC.OWNER_FLG, ' '
FROM CI_BATCH_CTRL BC WHERE TRIM(BC.PROGRAM_NAME)='com.splwg.base.domain.conversion.batch.CopyRecordsToStagingProcess'
AND NOT EXISTS (SELECT 'X' FROM CI_BATCH_CTRL_P BCP WHERE BCP.BATCH_CD = BC.BATCH_CD AND BCP.BATCH_PARM_NAME = 'allowAppendTable')
/

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', 'Append to Existing Data', 'By default, data may only be inserted to an empty table. Set to ''Y'' to append new records to existing data.', 1, BCP.OWNER_FLG
FROM CI_BATCH_CTRL BC, CI_BATCH_CTRL_P BCP WHERE BC.BATCH_CD = BCP.BATCH_CD
AND TRIM(BC.PROGRAM_NAME)='com.splwg.base.domain.conversion.batch.CopyRecordsToStagingProcess'
AND BCP.BATCH_PARM_NAME = 'allowAppendTable' AND NOT EXISTS (SELECT 'X' FROM CI_BATCH_CTRL_P_L BCPL WHERE BCPL.BATCH_CD = BCP.BATCH_CD AND BCPL.SEQ_NUM = BCP.SEQ_NUM AND BCPL.LANGUAGE_CD = 'ENG')
/
