-- MOPDB
INSERT INTO CT_MRDS.A_TASK_HISTORY_SOURCE (
	A_TASK_HISTORY_SOURCE_KEY,
	A_TASK_HISTORY_KEY,
	A_WORKFLOW_HISTORY_SOURCE_KEY,
	SOURCE_NAME,
	ROW_COUNT,
	SERVICE_NAME
)
SELECT 
  A_LOAD_HISTORY_SOURCE_KEY   AS A_TASK_HISTORY_SOURCE_KEY,
  A_LOAD_SUBPROCESS_FK        AS A_TASK_HISTORY_KEY,
  A_ODS_LOAD_SET_FK           AS A_WORKFLOW_HISTORY_SOURCE_KEY,
  CASE 
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_ADHOC_ADJ_HEADER'          THEN 'OU_LM_ADHOC_ADJUSTMENTS_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_ADHOC_ADJ_ITEM'            THEN 'OU_LM_ADHOC_ADJUSTMENTS_ITEM'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_ADHOC_ADJ_ITEM_HEADER'     THEN 'OU_LM_ADHOC_ADJUSTMENTS_ITEM_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_ADHOC_ADJ_ITEM_HEADER'     THEN 'OU_LM_ADHOC_ADJUSTMENTS_ITEM_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_CSM_ADJ_HEADER'            THEN 'OU_LM_CSM_ADJUSTMENTS_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_CSM_ADJ_ITEM'              THEN 'OU_LM_CSM_ADJUSTMENTS_ITEM'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_CSM_ADJ_ITEM_HEADER'       THEN 'OU_LM_CSM_ADJUSTMENTS_ITEM_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_STANDING_FACILITY'         THEN 'OU_LM_STANDING_FACILITIES'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_STANDING_FACILITY_HEADER'  THEN 'OU_LM_STANDING_FACILITIES_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_MRR_MRR_IND_CURR_ACC_HEADER'  THEN 'OU_LM_CURRENT_ACCOUNTS_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_MRR_MRR_IND_CURR_ACC_ITEM'    THEN 'OU_LM_CURRENT_ACCOUNTS_ITEM'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_QR_ADJ_HEADER'             THEN 'OU_LM_QRE_ADJUSTMENTS_HEADER'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_QR_ADJ_ITEM'               THEN 'OU_LM_QRE_ADJUSTMENTS_ITEM'
    WHEN SOURCE_TABLE_NAME  = 'OU_LM_QR_ADJ_ITEM_HEADER'        THEN 'OU_LM_QRE_ADJUSTMENTS_ITEM_HEADER'
    ELSE SOURCE_TABLE_NAME  
  END                         AS SOURCE_NAME,
  ROW_COUNT                   AS ROW_COUNT,
  'MOPDB'                     AS SERVICE_NAME 
FROM
    CT_MOPDB.A_LOAD_HISTORY_SOURCE
WHERE
    SOURCE_TABLE_NAME IN (
    'OU_LM_ADHOC_ADJ_HEADER',
    'OU_LM_ADHOC_ADJ_ITEM',
    'OU_LM_ADHOC_ADJ_ITEM_HEADER',
    'OU_LM_BALANCESHEET_HEADER',
    'OU_LM_BALANCESHEET_ITEM',
    'OU_LM_CSM_ADJ_HEADER',
    'OU_LM_CSM_ADJ_ITEM',
    'OU_LM_CSM_ADJ_ITEM_HEADER',
    'OU_LM_STANDING_FACILITY',
    'OU_LM_STANDING_FACILITY_HEADER',
    'OU_MRR_MRR_IND_CURR_ACC_HEADER',
    'OU_MRR_MRR_IND_CURR_ACC_ITEM',
    'OU_LM_FORECAST_HEADER',
    'OU_LM_FORECAST_ITEM',
    'OU_LM_QR_ADJ_HEADER',
    'OU_LM_QR_ADJ_ITEM',
    'OU_LM_QR_ADJ_ITEM_HEADER',
    'OU_LM_TTS_HEADER',
    'OU_LM_TTS_ITEM'
    );


COMMIT;	

