Delimiter //
/**
 * Author:  armen
 * Created: 26 sept. 2017
 */
Drop Procedure if exists LOADER_MATCHINGCODES_UPDATE//
Create Procedure LOADER_MATCHINGCODES_UPDATE (
    In batchnum int
)
Begin
        Update MATCHINGCODES MC
			Inner Join LOADER_MATCHINGCODES LM
				On MC.ID_MATCHINGCODES = LM.MATCHINGCODES_ID_MATCHINGCODES
			Inner Join LOADER_STATUS LS
				On LM.LOADER_STATUS_ID_LOADER_STATUS = LS.ID_LOADER_STATUS
		Set
			MC.MATCHINGCODES_DATE = LM.MATCHINGCODES_DATE
		Where
			LM.MATCHINGCODES_ID_MATCHINGCODES Is Not Null
			And LS.LOADER_STATUS_ERRCOUNT = 0
			And LS.LOADER_STATUS_BATCH_NUM = batchnum
		;
End //

Delimiter ;



