Delimiter //
/**
* doit être appelé apres LOADER_RECLAIMS_NORMALIZE_MAP_DETAILS_AMOUNT
**/
Drop Procedure If Exists LOADER_RECLAIMS_NORMALIZE_MAP_ORIGINAL_AMOUNT//
Create Procedure LOADER_RECLAIMS_NORMALIZE_MAP_ORIGINAL_AMOUNT(
    In batchnum Int
)
Begin

    Update
        LOADER_STATUS STS
        Inner Join LOADER_RECLAIMS LRD
            On LRD.LOADER_STATUS_ID_LOADER_STATUS = STS.ID_LOADER_STATUS
    Set
	-- si besoin faire la somme de tous les detail
	-- pour le momant inutil car 1 seul ecriture par reclamation
        LRD.RECLAIMS_ORIGINAL_AMOUNT =  LRD.RECLAIMS_DETAILS_AMOUNT
    Where
        STS.LOADER_STATUS_BATCH_NUM = batchnum
		And LRD.RECLAIMS_ORIGINAL_AMOUNT Is null
		And STS.LOADER_STATUS_ERRCOUNT = 0
    ;

End//
Delimiter ;
