--=============================================================================================================================
-- Add source system
--=============================================================================================================================

---- C2D

DELETE FROM CT_MRDS.A_SOURCE_FILE_RECEIVED r
WHERE EXISTS ( 
    SELECT 1 
    FROM CT_MRDS.A_SOURCE_FILE_CONFIG s 
    WHERE s.A_SOURCE_FILE_CONFIG_KEY = r.A_SOURCE_FILE_CONFIG_KEY AND s.A_SOURCE_KEY = 'C2D'
    );
/
COMMIT;
/

DELETE FROM CT_MRDS.A_SOURCE_FILE_CONFIG
WHERE A_SOURCE_KEY = 'C2D';
/

DELETE FROM CT_MRDS.A_SOURCE
WHERE A_SOURCE_KEY = 'C2D';
/
COMMIT;

---- TOP

DELETE FROM CT_MRDS.A_SOURCE_FILE_RECEIVED r
WHERE EXISTS ( 
    SELECT 1 
    FROM CT_MRDS.A_SOURCE_FILE_CONFIG s 
    WHERE s.A_SOURCE_FILE_CONFIG_KEY = r.A_SOURCE_FILE_CONFIG_KEY AND s.A_SOURCE_KEY = 'TOP'
    );
/
COMMIT;
/

DELETE FROM CT_MRDS.A_SOURCE_FILE_CONFIG
WHERE A_SOURCE_KEY = 'TOP';

DELETE FROM CT_MRDS.A_SOURCE
WHERE A_SOURCE_KEY = 'TOP';
/

---- CEPH

DELETE FROM CT_MRDS.A_SOURCE_FILE_RECEIVED r
WHERE EXISTS ( 
    SELECT 1 
    FROM CT_MRDS.A_SOURCE_FILE_CONFIG s 
    WHERE s.A_SOURCE_FILE_CONFIG_KEY = r.A_SOURCE_FILE_CONFIG_KEY AND s.A_SOURCE_KEY = 'CEPH'
    );
/
COMMIT;
/

DELETE FROM CT_MRDS.A_SOURCE_FILE_CONFIG
WHERE A_SOURCE_KEY = 'CEPH';
/
DELETE FROM CT_MRDS.A_SOURCE
WHERE A_SOURCE_KEY = 'CEPH';
/
COMMIT;