Delimiter //
/**
 * cette procédure purges les tables 
 * - LOADER_MATCHINGCODES, 
 * - LOADER_ENTRIES
 * - LOADER_STATUS
 * des données non issu du fichier source
 */  
Drop Procedure If Exists LOADER_ENTRIES_NORMALIZE_MAP_RECONCILIATION_PREP_LOADER_TABLES//
Create Procedure LOADER_ENTRIES_NORMALIZE_MAP_RECONCILIATION_PREP_LOADER_TABLES(
)
Begin
	
	-- supression des données de la table LOADER_STATUS
	-- il n'y as pas de FK est ça permet de simplifier les autres supressions
	Delete LOADER_STATUS From LOADER_STATUS Where LOADER_STATUS.SRC_TABLE_ID Is Null;

	-- supression des données de la table LOADER_ENTRIES
	Delete
		LOADER_ENTRIES
	From
		LOADER_ENTRIES
		Left Join LOADER_STATUS
			On LOADER_ENTRIES.LOADER_STATUS_ID_LOADER_STATUS = LOADER_STATUS.ID_LOADER_STATUS
	Where
		LOADER_STATUS.ID_LOADER_STATUS Is null
	;
	-- supression des données de la table LOADER_MATCHINGCODES
	Delete
		LOADER_MATCHINGCODES
	From
		LOADER_MATCHINGCODES
		Left Join LOADER_STATUS
			On LOADER_MATCHINGCODES.LOADER_STATUS_ID_LOADER_STATUS = LOADER_STATUS.ID_LOADER_STATUS
	Where
		LOADER_STATUS.ID_LOADER_STATUS Is null
	;
	

End//
Delimiter ;