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

---- LM

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 = 'LM'
    );
/

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

---- CSDB

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 = 'CSDB'
    );
/

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

COMMIT;